I am learning how to use terminal escape codes on Windows. I know how to move cursor position and how to do a few other things. But how do I receive input?
For instance, if I want to navigate around with the arrow keys, how would I do that?
I am learning how to use terminal escape codes on Windows. I know how to move cursor position and how to do a few other things. But how do I receive input?
For instance, if I want to navigate around with the arrow keys, how would I do that?
Keyboard input is usually platform specific. ncurses can be used on Linux and macOS while there exists an alternative library for Windows called pdcurses. Another option is <conio.h> which is offered by most C compilers that target Windows including mingw.
<conio.h> lets you use _getch() and _getwch() which are functions that get a character from the console. A link to them: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/getch-getwch?view=msvc-170
Here is a SO question that uses _getch() to detect when the arrow keys are pressed: how to detect the ESC key in C?
Edit, this might help as well: https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences