I need to detect a keystroke, without the user pressing enter. What\'s the most elegant way?
I.e. If the user hits the letter Q, without pressing ent
In unix/posix, the standard way of doing this is to put the input into non-canonical mode with tcsetattr:
#include
#include
:
struct termios attr;
tcgetattr(0, &attr);
attr.c_lflag &= ~ICANON;
tcsetattr(0, TCSANOW, &attr);
See the termios(3) man page for more details (and probably more information than you wanted to know).