Search code examples
javaeventsevent-handlingkeyevent

Key events on application level in Java


Is it possible to be notified of key events on an application level and not on a Component level? What i mean by application level is not having a swing component receive key events but to have a special class listen to system wide key events.

This could be used in an app with no GUI for instance or when a more global handling of key events is needed.


Solution

  • Not sure if it is possible in native Java: in Windows, you have to create a DLL to hook key events at the system (global) level, I suppose it is a different mechanism in Unix or MacOS, so you have to interface to low level system API to get this done.