I'm developing a Java application that gets input and sends output to the system console (System.in, System.out). I need to detect the pressing of a certain key (say the 'A' key for example) right when it happens without waiting for the user to press enter.

So for example, say the program is set to do the following when the 'A' key is pressed.
System.out.println("YOU PRESSED THE A KEY");
If someone were typing the word "roman" this would happen:
I know there is no method already in place to handle this, so I'm looking for a work-around. I thought I could setup something like a JFrame that implements KeyListener and just leave the frame invisible, but apparently components can only get focus if they are visible, and can only detect keys when they are in focus.

Is there any way whatsoever to detect a keypress without implementing a GUI? I'm looking for a pure Java solution... not calls to system-specific libraries.

Thanks very much to anyone who can help!