View Single Post
  #1 (permalink)  
Old 04-01-2008, 06:37 PM
Sreejesh25 Sreejesh25 is offline
Member
 
Join Date: Apr 2008
Location: Banglore,India
Posts: 4
Sreejesh25 is on a distinguished road
getting each character from keyboard
I want to read each character from the keyborad to do some action on each key.
But the System.in.read() was waiting for ENTER key to be pressed.
I want System.in.read() returning one character each time I'm pressing one character on the keyboard.
Please help...
The code is like this.

int ch;
while ('\n' != (ch = System.in.read())) {
System.out.println("You pressed " + ch
+ ".System waiting for next character.Press ENTER to exit");
}



System.in.read() should not wait for the user to press the ENTER key.
Reply With Quote
Sponsored Links