This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Press any key to continue...

 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you put in the functionality to pause the program until the user presses any key, then the program will continue on?

I know there are some easy ways to do this in C but I haven't seen any in Java. Do you have to write some native code in order to do this?

Any help is appreciated. (and please no Scanner.nextLine() stuff. I don't want the user to have to press enter, I want them to press any key to continue.)

Thanks!!
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say that reading from System.in is all you need, but it blocks until the user presses enter. Quite a shame.
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes quite!! I only want to block until the user presses any key.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!