JNativeHook is a library to provide global keyboard and mouse listeners for Java. This will allow you to listen for global shortcuts or mouse motion that would otherwise be impossible using pure Java. To accomplish this task, JNativeHook leverages platform-dependent native code through Java's native interface to create low-level system-wide hooks and deliver those events to your application.
The following events are available via their respective listeners.
In addition to global event listeners, this library has the ability to post native events back to the native operating system.
Binary distribution for JNativeHook can be found at the
releases section of the
project page. Maven users can
use the <groupId>com.1stleg</groupId>
and <artifactId>jnativehook</artifactId>
to include this library automatically. The nightly builds can be found at the maven
snapshot repository.
If you have found this library useful, please consider making a donation.
Detailed instructions to compile from source are available in the wiki.
The graphical example application was created to provided a real-time demonstration of raw output for all available native events. To run the application simply execute the jar file provided. Source code available at src/java/org/jnativehook/example/NativeHookDemo.java.
Up to date source code and documentation available at: https://github.com/kwhat/jnativehook/