Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to detect ENTER key from console app?

 
Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic