This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to receive key events when your application doesn't have focus ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to receive key events when your application doesn Watch "how to receive key events when your application doesn New topic
Author

how to receive key events when your application doesn't have focus ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

hi, I need to create an Handler , which i will attached to the keyboard handler to receive "key events" even though my application doesn't have focus (this is my projects requirement) but i m not sure how i can do that with java , if any one has done similar work , your comments are really appreciated.


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

You can't do that in pure Java.


luck, db
There are no new questions, but there may be new answers.
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

You can have a look at SWT. I don't think it will have an API to do exactly what you want, but you might be able to find something useful in the code snippets. You might have to go as far as writing some low-level C or C++ code to hook into the Desktop Key events. Via JNI you can have your event call your Java code if needed.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to receive key events when your application doesn't have focus ?