A terminal app doesn’t get “keys”, it gets bytes.
- Normal characters like
aarrive as the literal byte fora. - Special keys (arrows, Home/End, function keys, etc.) usually arrive as escape sequences: short strings that start with the ESC character (
\x1b).- In
cat -v, ESC shows up as^[.
- In
- So
^[OHmeans the three bytes:ESCthenOthenH.