You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
have access to post topics
communicate privately with other members (PM)
not see advertisements between posts
have the possibility to earn one of our surprises if you are an active member
access many other special features that will be introduced later.
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.
I have searched for ages trying to find the answer but it appears that you can't get anything from System.in without the 'enter' key being pressed. Unfortunately it doesn't seem possible.
__________________ Did this post help you? Please To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. me! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. || Don't forget to: To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.