Capturing the input stream as a user types
I am working on a C++ based command line tool and I want to capture the user's keystrokes in real-time without requiring them to hit Return
to commit the input. I can't seem to find an iostream call to support this kind of behavior but I recall from my college years th开发者_运维百科at it can be done. Can anyone point me in the right direction?
That is outside of the C++ spec and requires OS specific calls. On Posix, you do this by enabling raw or cbreak mode instead of cooked mode.
The easiest way to enable this is via curses.
精彩评论