开发者

Capturing the input stream as a user types

开发者 https://www.devze.com 2022-12-26 02:19 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消