Sign in to follow this  
Leigher

[C++] Immediate reaction after receiving input from keyboard.

Recommended Posts

Hello again, I've run into this little problem. I need to be able to extract what someone wrote into the console without him pressing ENTER, for example when asked to press y or n, as soon as the user presses the button some action is taken, instead of having to wait for him to press the letter and then press enter. I've tried to look for solutions to this in the iostream library, but none of the methods in the cin object seem to do what I need. How would I go about doing this?

Share this post


Link to post
Share on other sites
The C++ standard library has no support for this. You'll need to look at OS specific functionality (such as kbhit() and getch()) or third party libraries (like ncurses or pdcurses).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this