tweak wording
add comments and reorg a little
Change key handling for faithful representation of escape sequences, even the ones we don't include in our keymap. This is irrelevant to this program, but means you could use gen_keys() in other programs.