How can I check and see if a key was pressed?

How can I check and see if a key was pressed?




How can I check and see if a key was pressed? On DOS I use the
kbhit() function, but there doesn't seem to be an equivalent?




If you set the terminal to single-character mode (see previous answer),
then (on most systems) you can use select() or poll() to
test for readability.






Home FAQ