Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java system-wide keyboard and mouse state

Is there a way to listen to the mouse and keyboard events system-wide without taking these out of system queue?

E.g. is there a way to set a demon, let's say, which would listen and report each and every keyboard and mouse event?

like image 358
shybovycha Avatar asked Dec 10 '25 14:12

shybovycha


1 Answers

It's not possible using pure Java. But you can use JNI (Java Native Interface), which is working on code written in C++ and natively compiled. So, this way you can write the Global KeyListener in C++ and let make Java use of it.

There is an active project implementing this for Linux, OS X and Windows: http://code.google.com/p/jnativehook/

like image 155
Martijn Courteaux Avatar answered Dec 12 '25 02:12

Martijn Courteaux



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!