Get input without using the enter key

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LadyMadonna
    New Member
    • May 2015
    • 1

    Get input without using the enter key

    Hi, I'm trying to do something quite simple, but I can't figure it out. I want to get some kind of input from the user, but without them having to press enter.
    is there any way that is simple and can do the trick? Is there a command for the system like system.("PAUSE" ) that I can use? I'm only working on C++ (not C at all). Thanks.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    When you call the operator>> using cin and your variable, that function does not return until the entered data has processed into your variable. That process will not occur until you press the enter key.

    To get around the requirement to press the enter key you will need to write your own class and do your own input process. Not an easy job.

    cin is provided (like scanf) in C just to get you started.

    Some operating systems, like Windows, have provided their own input process and don't use cin at all. Check your OS and see if this has been done for you. Of course, you will need to follow the rules of the OS input process.

    Comment

    • computerfox
      Contributor
      • Mar 2010
      • 276

      #3
      Does the project have to be in C++?
      I know web languages like JavaScript are able to read the input without enter.
      You basically need something that checks if the content of the object has changed.
      I'm not aware of any basic way that C/C++ can do this without you writing your own buffer which can get pretty messy.

      Comment

      Working...