my dog learned polymorphism*
The moose likes Beginning Java and the fly likes How to detect ENTER key from console app? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to detect ENTER key from console app?" Watch "How to detect ENTER key from console app?" New topic
Author

How to detect ENTER key from console app?

Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Hi,
I want the user who can press the ENTER key and then go to the next function. e.g. Press ENTER key to calculate the number of year.
How can I use it with System.in?
Thanks for help
Andrew
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
With System.in, enter is the only key press you can detect as soon as it happens. If you call readLine() it will return as soon as the user hits enter. The user may have typed other things as well, but you can ignore them.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to detect ENTER key from console app?
 
Similar Threads
when press key enter then an action is performed ..
Capturing "Enter Key" Value in Javascript
Regarding Action and KeyEvents
Regarding Listener
Submitting a form on pressing Enter key