Reading keyboard state without keylistener ??

A

axel.kowald

Hi everybody,

I would like to read the current keyboard state (is button X pressed)
without a keylistener.
The problem is that I need to recognize a keypress in my java
application even if the application is not the foreground window and
has no keyboard focus.

My application runs in a looping thread and during each cycle I want
to check the current state of the keyboard.
How can I do this?

Many thanks,

axel
 
A

Andrew Thompson

...need to recognize a keypress in my java
application even if the application is not the foreground window and
has no keyboard focus.

I doubt it can be done in pure Java. Try JNI.
 
C

cyprian

(e-mail address removed) wrote:

..


I doubt it can be done in pure Java. Try JNI.

the focus hierarchy flows from Windows before it gets to your
component, you'll always get a FOCUS_LOST response because the window
that is the focus cycle root will return DEACTIVATED, no show in java
for that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top