Question

I am trying to use keystrokes to affect my program. For example, I have a program that prints numbers continuously. I want it to stop printing numbers if I enter Ctrl+E. How can I do this on C++?

I have read about a number of headers like conio.h but they are not built in the C library. I would like this to be kept as pure C/C++ as possible.

No correct solution

OTHER TIPS

you can use GetAsyncKeyState function for this.

It is there in Winuser.h file

That depends on the operating system - hence impossible in 'pure' C/C++. I fear you have to go with #ifdef SYSTEM_A, ... Please notice, The languages C/C++ are not aware of any kind of hardware (keyboard in this case), they know streams.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top