Hacker News new | ask | show | jobs
by JasuM 3091 days ago
I spent yesterday rewriting my ZSH config. A lot of the time I spent on figuring out how to map random key combos to unused control characters. So if I could implement both the terminal and the shell from scratch (or make a significant addition), I would implement a scenario like this:

  1. Program informs the terminal that it supports "extended keyboard input". This would be done with an escape code, much like bracketed paste.
  2. Terminal informs the program that it is now enabled.
  3. Terminal informs the program of the initial modifier key state.
  4. When the user presses a key (including modifiers), it is sent in a format that standardizes over all the commonly used key codes. Also, if the key represents a Unicode codepoint, that is sent as well. E.g. (mod-status-at-key-press)(key-code)(utf8-char-or-null)(null-terminator).
  5. When the user releases a key, a similar message would be sent.
  6. When the program exits (or a shell runs another program), it asks the terminal to disable "extended keyboard input"