File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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.
 
 
subject: How to detect ENTER key from console app?