I'm making a strictly command prompt program and at some point i'd like to make its execution pause until the user presses a key on the keyboard (whichever would it be).
So far I tried this:
char cont =sc.next().charAt(0);
while(cont !=' ') {
try{
Thread.currentThread().sleep(1);
} catch(Exception e) {
System.out.println(e);
}
cont = sc.next().charAt(0);
}
In this case I wanted 'space' to resume the execution but i'd rather make any input do the trick.
EDIT: To be more specific, I'd like the program to resume instantly at any pressed key, without letting the user see what he gave as inputs.