listening to keyboard events


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: listening to keyboard events

  1. #1
    Join Date
    Mar 2005
    Posts
    2

    Question listening to keyboard events

    An expert advise needed:
    my program should listen to all keyboard events and record them.

    problems:
    1) I don't know how to organise listening not through Swing (or any GUI component), but somehow directly.
    2) I don't know how to listen to the events when my program is 'focused' out.
    3) maybe its better idea to write in C++

    thanks for any help

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    1: Check out the KeyListener interface
    2: Your program can't listen to anything when it is focused out, maybe write some code
    that the program can execute when nobody is using it ?
    As fopr java components, use the requestFocus method.
    3: Yes, if you know nada about the java listener concept and you don't have to do it in java. But if you have to do it in java I think you would be better off with some
    sun documentation & tutorials first.
    eschew obfuscation

  3. #3
    Join Date
    Mar 2005
    Posts
    2
    thanks for reply, sjalle!

    have already checked the KeyListener, it works fine when listens to the keyboard events through the GUI elements (e.g. Textfield), so both - my programm must be focused and the GUI component must be focused to get the event. My aim is to get keybord events with my programm e.g. while writing word document... or writing a password in internet bank

    so at the moment I don't see the solution in JAVA, but I see it in C++, quite complicated for me though, but won't give up

  4. #4
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    I can imagine intercepting ms-word keystrokes may be difficult. I honestly cannot
    think of any way of doing that with java unless you somehow managed to 'wrap'
    your textprocessor in java, and fed it the keystrokes through your application, or
    an operating system hack (I'm talking windows now..)/some assembler snipped
    between the keyboard feed and the OS......
    eschew obfuscation

  5. #5
    Join Date
    Apr 2005
    Posts
    4
    gunny,

    I suppose that all you need is the system keyboard hook...
    You can check http://www.jniwrapper.com/winpack_features.jsp#hooks

    This solution allows to track (and record if necessary _all_ keyboard events from your Java application without the native code.

    Good Luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center