Reading keyboard state without keylistener ??

Discussion in 'Java' started by axel.kowald@rub.de, Jun 11, 2007.

  1. Guest

    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
    , Jun 11, 2007
    #1
    1. Advertising

  2. 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
    Andrew Thompson, Jun 11, 2007
    #2
    1. Advertising

  3. cyprian Guest

    On Jun 11, 3:31 pm, "Andrew Thompson" <u32984@uwe> wrote:
    > 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.
    cyprian, Jun 11, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Shaw
    Replies:
    1
    Views:
    843
    J. Romano
    Nov 10, 2003
  2. apchar
    Replies:
    3
    Views:
    1,845
    Andrew Hobbs
    Feb 3, 2004
  3. JariTapio

    KeyListener vs. Runnable ???

    JariTapio, Mar 25, 2005, in forum: Java
    Replies:
    2
    Views:
    734
  4. Max

    JWindow KeyListener

    Max, Oct 29, 2005, in forum: Java
    Replies:
    4
    Views:
    3,776
  5. Luc The Perverse

    KeyListener

    Luc The Perverse, Nov 12, 2005, in forum: Java
    Replies:
    2
    Views:
    799
    Luc The Perverse
    Nov 12, 2005
Loading...

Share This Page