开发者

Java: how to accomplish isKeyDown() functionality that is independent from java components? [duplicate]

This question already has answers here: React on global hotkey in a Java program on Windows/Linux/Mac? (6 answers) Closed 8 years ago.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜