Is it possible to send a control sequence to a terminal emulator using the keyboard

escape-charactersterminalterminal-emulatorxterm

If you type echo -e '\eZ' and hit return in a shell running in an xterm, you'll see that the terminal emulator prints an obscure code 1;2c. This seems to indicate that xterm interprets the VT100 control sequence \eZ (ESC Z, return terminal ID) and acts accordingly.

Now, if you press ESC Z in the same console, nothing happens. Does this mean that it is not possible to send control characters directly using the keyboard?

I'm not sure what is happening here, because pressing CTRL s (control flow) does stop the console output until you press CTRL q. So why does CTRL s/q work and not ESC Z?

Best Answer

VT100s responded to character sequences sent to them as output. So echo'ing characters works because the terminal sees it as output. Typing characters is input; the terminal will respond only if the characters are echoed by the receiving computer. Your typical shell doesn't echo ESC, it interprets ESC as the prefix for some interactive input command. Run cat and type ESC Z RETURN and you'll see the usual VT100 response.

Related Question