Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Reading keyboard state without keylistener ??

Reply
Thread Tools

Reading keyboard state without keylistener ??

 
 
axel.kowald@rub.de
Guest
Posts: n/a
 
      06-11-2007
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

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      06-11-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
...
>...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.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via http://www.javakb.com

 
Reply With Quote
 
 
 
 
cyprian
Guest
Posts: n/a
 
      06-11-2007
On Jun 11, 3:31 pm, "Andrew Thompson" <u32984@uwe> wrote:
> (E-Mail Removed) wrote:
>
> ..
>
> >...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.
>
> --
> Andrew Thompsonhttp://www.athompson.info/andrew/
>
> Message posted viahttp://www.javakb.com


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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
KeyListener losing its way JavaEnquirer Java 0 12-20-2005 05:00 PM
KeyListener Luc The Perverse Java 2 11-12-2005 09:27 AM
JWindow KeyListener Max Java 4 10-29-2005 04:24 AM
KeyListener vs. Runnable ??? JariTapio Java 2 03-25-2005 02:06 PM
Wierd problem with KeyListener and contentPane in applet. apchar Java 3 02-03-2004 04:10 AM



Advertisments