Capture characters from standard input without waiting for enter to be pressed

I can never remember how I do this because it comes up so infrequently for me. But in C or C++, what is the best way to read a character from standard input without waiting for a newline (press enter).

Also ideally it wouldn’t echo the input character to the screen. I just want to capture keystrokes with out effecting the console screen.

21 Answers
21

Leave a Comment