Results 1 to 7 of 7
- 04-01-2008, 05:37 PM #1
Member
- Join Date
- Apr 2008
- Location
- Banglore,India
- Posts
- 4
- Rep Power
- 0
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.
- 04-02-2008, 05:31 PM #2
This is an interesting question.
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. :confused:Did this post help you? Please
me! :cool:
- 04-10-2009, 11:06 PM #3persikaspacesen Guest
Wild granny and mature
Collection of maturess
- 04-10-2009, 11:43 PM #4
You could use Swing and listen for key events.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
-
Old zombie thread
- 04-11-2009, 02:16 AM #6
Blast. Note to self - check the date.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 03-05-2010, 07:12 PM #7
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
Similar Threads
-
getting each character from keyboard
By Sreejesh25 in forum New To JavaReplies: 11Last Post: 01-25-2011, 01:08 PM -
Polled keyboard input through swing
By Prometheus in forum Advanced JavaReplies: 2Last Post: 02-04-2008, 04:05 PM -
Assign a keyboard key to a JButton.
By gszauer in forum AWT / SwingReplies: 1Last Post: 12-15-2007, 10:42 PM -
reading text character by character
By bugger in forum New To JavaReplies: 2Last Post: 11-09-2007, 08:54 PM -
Help with keyboard events?
By Bibendum in forum New To JavaReplies: 2Last Post: 11-02-2007, 02:51 AM


LinkBack URL
About LinkBacks

Bookmarks