How to make program quit if user presses ESC key?
posted 12 years ago
Not easily done. You can't read a single key press off of the console in Java without resorting to native code. You can add a key listener to a GUI component but you will only get key presses if the component has focus. If you make a frame a key press listener and a button on the frame has the focus the frame will not get the event. Tell your users it is the 21st century, pick up a mouse!