View RSS Feed


Adding "Global" KeyListener

Rating: 1 votes, 5.00 average.
by , 10-17-2011 at 07:00 PM (9747 Views)
Want to add a so called "Global" Keylistener to your Java application even if it is a JWindow or JFrame without having focus on it. Just download the file in the link and extract, add the jhook.jar file to your project library and use this demo code to get the keys pressed.

Java Code:
Keyboard kb=new Keyboard();
        kb.addListener(new KeyboardListener() {
            public void keyPressed(boolean keydown, int vk){
paulsauer98 likes this.

Submit "Adding "Global" KeyListener" to Facebook Submit "Adding "Global" KeyListener" to Digg Submit "Adding "Global" KeyListener" to Submit "Adding "Global" KeyListener" to StumbleUpon Submit "Adding "Global" KeyListener" to Google

Updated 10-19-2011 at 09:33 AM by DuvanSlabbert

AWT and Swing


  1. JavaForums's Avatar
    • |
    • permalink
    Hi Duvan,

    Thanks for sharing.

    I have a question. Does this work for only windows?

    By the way, why didn't you attach the code to the post? Did you observe a limitation?
  2. DuvanSlabbert's Avatar
    • |
    • permalink
    I have searched long and wide to get a cross-platform version for doing this, even tried some funny things of implementing keyListeners to threads... but with no success. Unfortunately this is only for Windows, my search will still go on until I get the so called "Global Keylistener" effect in java which is cross-platform based. The file in a zipped format is just under a Meg in size and was restricted to the maximum of 97.7kb
  3. AlphaSupport's Avatar
    • |
    • permalink
    Hello Duvan,

    We have now raised the filesize limit for ZIP-files to 15Mb.

    Can you please test attaching the file directly to your post now?

  4. DuvanSlabbert's Avatar
    • |
    • permalink
    It works without any further problems.
    Thank you so much.
    Updated 10-19-2011 at 09:03 PM by DuvanSlabbert