Keyboard Input
Low-level keyboard input primitives
Quick Start
main.py
getch
Read single character without waiting for Enter:
main.py
Works on both Unix (termios) and Windows (msvcrt).
read_key
Read key with arrow/escape sequence handling:
main.py
Return Values
| Input | Returns |
|---|---|
| Arrow Up | 'up' |
| Arrow Down | 'down' |
| Arrow Left | 'left' |
| Arrow Right | 'right' |
| Escape | 'esc' |
| Enter | '\\n' or '\\r' |
| Regular char | The character |
Example: Navigation Loop
main.py
Platform Support
Unix/macOS
Uses termios + tty
Windows
Uses msvcrt
