C++ FAQ Celebrating Twenty-One Years of the C++ FAQ!!!
(Click here for a personal note from Marshall Cline.)
Section 15:
[15.17] How can I tell {if a key, which key} was pressed before the user presses the ENTER key?

This is not a standard C++ feature — C++ doesn't even require your system to have a keyboard!. That means every operating system and vendor does it somewhat differently.

Please read the documentation that came with your compiler for details on your particular installation.

(By the way, the process on UNIX typically has two steps: first set the terminal to single-character mode, then use either select() or poll() to test if a key was pressed. You might be able to adapt this code.)