I have a C++ application running on Ubuntu that waits for a key press using getchar() function. The input is not used, I just end my program with any keypress.
I noticed I could type basically any printable character, but also some unprintable characters such as the escape and backspace keys. Keys that did not trigger the ending of my program were keys such as shift and ctrl.
So my question is, which key presses get read by getchar()? How can I classify those, since apparantly not only printable characters trigger getchar()?
I could not find the answer in the man page or the C++ reference.
This is basically all the code I wrote:
std::cout << "Ready for input ..." << std::endl;
std::getchar();
std::cout << "A key was pressed, landing ..." << std::endl;
Mind that I do manipulate termios to not wait for a newline character and to not echo.
So it turns out the keys that getchar() does not catch are Modifier keys. Maybe just because they are simply "modifiers" and always are used together with another key to create a specific charater. If anyone knows the particular reason, I would like to know.