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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kotoro
    New Member
    • Nov 2006
    • 32

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

    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.
  • kotoro
    New Member
    • Nov 2006
    • 32

    #2
    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.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      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.

      Comment

      • kotoro
        New Member
        • Nov 2006
        • 32

        #4
        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.

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by kotoro
          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.

          Comment

          Working...