This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Detecting Key Presses in Windows (without focus) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

Detecting Key Presses in Windows (without focus)

Micho Lee

Joined: Oct 21, 2003
Posts: 14
I'm writing a java application that runs in the background in a Windows XP environment. I need a way for the application to detect when certain keys have been pressed on the keyboard even when it is not in focus. Kind of like a key logger would do, I need it to detect any keys that might be pressed. Does anyone know how to implement such a "global" key listener so that a key press can be captured at any/all times within Windows?

Help (esp exaple code) would be much appreciated. Thanks in advance!
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Please don't cross-post. It wastes our time because an answer may have already been given in another forum. See my comments here.


p.s. Can a sheriff please close this thread? Thanks.

Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: Detecting Key Presses in Windows (without focus)