I've used the Robot class in java numerous times as a quick workaround on menial tasks. Stopping execution is always a problem (which needs to be numerous times during testing). What I want is a KeyListener that will listen for a key/combination of keys and will stop the program. From my brief readings, it seems you can't embed a key listener without a frame or something of the like in focus. To me, focus means the forefront window. Is this the wrong definition? If this is the correct definition, I can't keep the window in focus because I am crawling around with my robot. How can I solve this problem?
While typing this, I came up with an un-ideal solution of programmatically bringing the window into focus, testing for the keypress, then programmatically bringing it out of focus and continuing. Is this possible? Is there a better way?