Java: how to accomplish isKeyDown() functionality that is independent from java components? [duplicate]
With Java, I need to detect whether a given key (using it's keyCode) is pressed down or not at a certain moment in time.
You might suggest for me to create an event listener for all keys for a certain component and store all keys' states (pressed down or not). However, I need to know whether a key is pressed down in general, and not for a certain Java component.
For example, if my Java application is running in the background and a user has a key pressed down inside OpenOffice, I need to be able to 开发者_开发问答detect so.
How would I accomplish this isKeyDown() functionality that is independent from java components within Java?
Any feedback is appreciated.
Can't be trivially done in Java. At best you can try JNI
精彩评论