Click to See Complete Forum and Search --> : How can I get pressed key in Java like getch() in C or C++


Zerge
September 27th, 1999, 05:40 AM
System.in.read() method give string at one time, and don't give anything until I press Enter. I need something like getch() in C.

ashwani singhal
September 29th, 1999, 07:24 AM
Use java.lang.System.in.read() function in try catch block

October 4th, 1999, 06:42 PM
If you are not using a DOS environment or such and want to catch key presses in say a windowed application or an applet, you can use the deprecated keyDown() or keyUp() methods. Or, you could implement the KeyListener interface and utilize the keyPressed(), keyReleased(), and keyTyped() methods. Just a thought. :)