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 use and configure, check out the setup documentation. For advanced usage, check out the configuration reference and custom instrumentation API. Confused about the terminology of APM? Take a look at ...