As the other poster mentioned, I'm not aware of any terminal that allows these sequences these days.
This wasn't an uncommon thing back in the 90s with DOS ANSI art. I'm not sure if the original ANSI.SYS included with DOS 5/6 but there was a period of time where people remapped things like "echo y|format c:" using ANSI that only required one to "type somefile.ans/txt". The "fix" was to use an accelerated ANSI driver that dropped key-remapping.
oh my god. From http://www.termsys.demon.co.uk/vtansi.htm :
> Set Key Definition <ESC>[{key};"{string}"p
> Associates a string of text to a keyboard key. {key} indicates the key by its ASCII value in decimal.
But I can't reproduce it; in my terminal (gnome-terminal), `print('\x1b[97;"echo foo"p')` just shows `cho foo"p`.
So it looks like not all terminals implement it, if any?