FWIW, in a low-level cross-terminal API, I made up some concepts that seemed helpful (and there are also a few comments scattered in there, such as hints about why key mapping is less consistent than one would've guessed): https://www.neilvandyke.org/racket/charterm/#%28part._.Termi...