Reputation: 8702
I'm trying to make a kind of a keylogger in Java. I got an app that allowed people to get their RSS feeds on their desktop and I want to make a quick access. By the way, I need something that can do that:
My app has to be totally cross platform. All things are done except this feature.
I've tried to do it with KeyStroke
and even System.in
but they only catch key combination when the user has the window as active.
So, is there a way to catch key combination from outside the app (Like a transparent overlay) without using JNI or JNA (That's what my searches gave me).
Thanks for your help.
Upvotes: 3
Views: 590
Reputation: 35011
This cannot be done. No operating system worth its salt in today's world will let you just log all keystrokes
Upvotes: 0
Reputation: 420991
No, you'll have to drop to some system dependent library, i.e. use some form of JNI.
The different built-in levels of granularity are:
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is an ancestor of the focused component or is itself the focused component.
WHEN_FOCUSED
Constant used for registerKeyboardAction that means that the command should be invoked when the component has the focus.
WHEN_IN_FOCUSED_WINDOW
Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component
Upvotes: 0