I just remembered an old problem I once had. I once needed to detect a keypress for a game (e.g. user presses C and program takes the appropriate action without waiting for him to press ENTER). At the time I used the conio.h library's getch() function.
Later I found out that this was not standard (not ANSI?) and not very portable.
So is there a good way of detecting a keypress in C? It's just a matter of curiosity at this point.
In Windows, there's GetAsyncKeyState, but I don't know of any standard C or C++ instruction.
Nothing standard or truly portable, it's all OS specific.
As mentioned before. It is OS specfic. There is no protable way of doing this. There is a good FAQ on this topic. Which explains solution on to main OS platforms.
Go through this FAQ