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.
Printable View
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.
Use java.lang.System.in.read() function in try catch block
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. :)