I am working on a Java application that gets input and sends output to the system console (System.out and System.in). I need to detect the pressing of a certain key right when it is pressed... not once the user presses enter.
For example, say I need to detect the pressing of the 'A' key, and when that happens, the program will do System.out.println("YOU PRESSED THE A KEY");
If a user tries to type the word "roman" this will happen:
romaYOU PRESSED THE A KEY
n
I hope that makes sense. I know there is no method for doing this, but any work around would do, including creating an invisible component to implement a KeyListener (though from what I have seen, components can only listen for keys if they are visible). Also, I need to do this using pure Java, not system-specific libraries.
Thanks very much to anyone who can help!
2007-03-28
18:44:07
·
3 answers
·
asked by
Stephen W
1