user3341281
user3341281

Reputation: 1

detecting any keystroke in java

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

Answers (1)

Andy Niles
Andy Niles

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

Related Questions