• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't do that in pure Java.
 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic