I understand that what you want is to read the direct inputs of the keys, without going through the buffer input std::cin
.
In that case, the answer is simple: no There is a standard way, since it depends on the operating system you use.
If you're in the console emulation of Windows, you know what to use: conio.h
If you use a graphical application, you have no choice but to resort to the system of events provided by the operating system, or the library of highest level you use.
The most portable mode would be using the ncurses library. Although it is native to * nix systems, it can be used in Windows terminal emulators. In chapter 11 of NCURSES Programming HOWTO
, Interfacing with the keyboard
, you have a complete example.
As a last option, if you are in Linux, you can set the keyboard in raw mode, directly accessing the events it generates. You have a complete example in Grab Raw Keyboard Input
.