Reputation: 1
I'm writing a program that needs to wait until any key is pressed. For example:
System.out.println("press any key to continue");
//wait until any keystroke
obj.doSomething;
the key that is pressed doesn't matter and I don't need to capture what key was pressed, I just need the program to wait until a key is depressed to continue.
Upvotes: 0
Views: 98
Reputation: 36
The official Java Tutorials describe how to implement Key Listeners for this purpose:
http://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html
Upvotes: 1