JInputHook

Global Key and Shortcuts listeners for Java.

License

License

GroupId

GroupId

com.github.dyorgio.runtime
ArtifactId

ArtifactId

jinputhook
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

JInputHook
Global Key and Shortcuts listeners for Java.
Project URL

Project URL

https://github.com/dyorgio/jinputhook
Source Code Management

Source Code Management

https://github.com/dyorgio/jinputhook.git

Download jinputhook

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.dyorgio.runtime/jinputhook/ -->
<dependency>
    <groupId>com.github.dyorgio.runtime</groupId>
    <artifactId>jinputhook</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.dyorgio.runtime/jinputhook/
implementation 'com.github.dyorgio.runtime:jinputhook:1.0.2'
// https://jarcasting.com/artifacts/com.github.dyorgio.runtime/jinputhook/
implementation ("com.github.dyorgio.runtime:jinputhook:1.0.2")
'com.github.dyorgio.runtime:jinputhook:jar:1.0.2'
<dependency org="com.github.dyorgio.runtime" name="jinputhook" rev="1.0.2">
  <artifact name="jinputhook" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.dyorgio.runtime', module='jinputhook', version='1.0.2')
)
libraryDependencies += "com.github.dyorgio.runtime" % "jinputhook" % "1.0.2"
[com.github.dyorgio.runtime/jinputhook "1.0.2"]

Dependencies

compile (1)

Group / Artifact Type Version
net.java.jinput : jinput jar 2.0.9

provided (1)

Group / Artifact Type Version
net.java.dev.jna : jna-platform jar 5.6.0

runtime (3)

Group / Artifact Type Version
net.java.jinput : jinput-platform jar 2.0.7
net.java.jinput : jinput-platform jar 2.0.7
net.java.jinput : jinput-platform jar 2.0.7

test (1)

Group / Artifact Type Version
junit : junit jar 4.13.1

Project Modules

There are no modules declared in this project.

JInputHook

Build Status Maven Central

Global Key and Shortcuts listeners for Java.

Why use it?

  • Create global keyboard/shortcut listeners.
  • As an alternative to excelent lib JNativeHook.

Usage

For shortcut listener:

// Initialize
JInputHook.initialize();
// Register shortcut listener
Shortcut shortcut = Shortcut.fromKeys(Key.LCONTROL, Key.LSHIFT, Key.D);
JInputHook.addShortcutListener(shortcut,
    new ShortcutListener() {
        @Override
        public void shortcutTriggered(Shortcut shortcut) {
            System.out.println("shortcutTriggered(" + shortcut + ").");
        }
    }
);

For keyboard listener:

// Initialize
JInputHook.initialize();
// Register global keyboard listener
JInputHook.addListener(new GlobalKeyListener() {
    @Override
    public void keyPressed(Key key) {
        System.out.println(".keyPressed(" + key + ").");
    }

    @Override
    public void keyReleased(Key key) {
        System.out.println(".keyReleased(" + key + ").");
    }
});

Maven

<dependency>
    <groupId>com.github.dyorgio.runtime</groupId>
    <artifactId>jinputhook</artifactId>
    <version>1.0.2</version>
    <!-- Optional classifier by OS, don't use classifier to support ALL -->
    <!--<classifier>mac-universal</classifier>-->
    <!--<classifier>linux-universal</classifier>-->
    <!--<classifier>win-universal</classifier>-->
</dependency>

Windows

On Windows, include JNA as dependency.

<dependency>
    <groupId>net.java.dev.jna</groupId>
    <artifactId>jna-platform</artifactId>
    <version>${your.jna.version}</version>
</dependency>

Linux

On Linux you need to adjust permissions of /dev/input/event* to can read:

sudo chmod o+r /dev/input/event*

Or, according with distro, create a new dev rule file on /etc/udev/rules.d/YOUR-FILE-NAME.rules:

SUBSYSTEM=="input", KERNEL=="event*", MODE="644"

Versions

Version
1.0.2
1.0.1
1.0.0