The moose likes I/O and Streams and the fly likes Read out of focus key press Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Read out of focus key press" Watch "Read out of focus key press" New topic

Read out of focus key press

Amol H Lekurwale

Joined: Aug 06, 2009
Posts: 9

I am developing a simple application, where in, there is no UI involved. My java code will be running as a background process. I want to make the program such that, if the user presses the key anywhere i.e. on any window running on the system, my program will be triggered and it will record the key pressed. In short, I want to listen to 'pure keyboard' without any focus concept getting involved. Is there any way to do so. and other things require focus on UI window.

Greg Charles

Joined: Oct 01, 2001
Posts: 2969

That's a tough one. It would involve tying into the event processing system of whatever operating system you are running on. That's more difficult to do in a language like Java than a lower level language like C, but it is possible. It would most likely involve using JNI (Java's native interface) and a thorough understanding of the underlying OS. However, there may be pre-written solutions out there yours for a Google search (and possibly some cash).
I agree. Here's the link:
subject: Read out of focus key press
jQuery in Action, 3rd edition