By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,265 Members | 1,282 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,265 IT Pros & Developers. It's quick & easy.

Need help implementing Console-based program pauses (Press Enter/Any Key to continue)

P: 32
I'm in an intro to computer programming course and just for the purposes of my test drivers and personal implementation, I would like to know if it is possible to force the program to wait for the enter key before proceeding without allowing the user to type in anything. I don't really have any experience with the buffered reader, we were provided with an IO class that handles inputs. Currently I solve it with a String input that doesnt go anywhere, but this looks unprofessional when you are able to type characters other than enter. (In professional programs that have "press enter to continue" generally nothing is shown when other keys are pressed. ) I'm willing to learn the whole buffered reader thing, but I currently don't know enough about it to even know if its the right tool for this or whether there is something else that performs this way.

I'm also interested in the "press any key to continue" operation if anyone knows how to implement this.
Nov 3 '06 #1
Share this Question
Share on Google+
4 Replies


P: 32
I know it appears that this issue has been dealt with in some other posts, but those answers still apparrently allow the user to type a string.
Nov 3 '06 #2

10K+
P: 13,264
You need a writer not a reader with a combination of KeyEvent handling. On keyPress write nothing to the console if the key is not enter.
Nov 3 '06 #3

P: 32
could you show me an example of this so I have an idea of how to implement it? I've never used key event or writer method calls, so I dont even know what their names are.
Nov 3 '06 #4

10K+
P: 13,264
could you show me an example of this so I have an idea of how to implement it? I've never used key event or writer method calls, so I dont even know what their names are.
I do not have any examples. If you are new to programming then it maybe a while before you do event handling.
Nov 3 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.