|
kaycxx-term
C++ terminal library
|
kaycxx-term provides minimal key input helpers. terminal::read_key returns the raw key byte sequence as a std::string.
read_key automatically switches to raw input mode when raw mode is not already active. When read_key enables raw mode itself, it restores the previous input state after the key has been read.
For manual control, use push_input_mode and pop_input_mode:
The input mode stack stores native terminal state snapshots, so nested pushes restore in last-in-first-out order.
On POSIX terminals, read_key returns the terminal's native byte sequence. Normal UTF-8 text input is returned as its UTF-8 bytes. Special keys such as cursor keys and function keys usually return escape sequences.
On Windows, console key events are mapped to POSIX-style escape sequences for cursor and function keys. Normal Unicode input is encoded as UTF-8 where possible.
This is intentionally low-level. Higher-level key event parsing can be built on top without hiding what the terminal actually produced.