Strovent SystemsSign in
App guide

What the keyboard sends in a VT session

The exact bytes the app sends for Esc, Backspace, Delete, Home, End, arrows with Ctrl or Alt, Shift+Tab, function keys and Ctrl chords in an SSH, Mosh or Telnet VT session, and how to see what a key sends.

In a VT session, every key goes to the host as bytes, except a few app shortcuts. This page lists what each key sends. Which of them a program understands depends on the program and on the terminal type the host thinks you have: see Keys and key codes and TERM and terminfo.

Esc without an Esc key

A keyboard with no Esc key can still send it:

Key table

ESC is the byte 0x1B. A modifier number is added to cursor and editing keys: 2 is Shift, 3 is Alt, 4 is Shift+Alt, 5 is Ctrl, 6 is Ctrl+Shift, 7 is Ctrl+Alt and 8 is all three.

  • Esc: ESC. With Alt, ESC ESC.
  • Backspace: 0x7F (DEL). With Ctrl, 0x08 (^H). With Alt, ESC then 0x7F.
  • Delete: ESC [ 3 ~
  • Tab: the Tab character. With Shift, ESC [ Z.
  • Return: carriage return. In the host's new-line mode, carriage return and line feed.
  • Up, Down, Right, Left: ESC [ A, B, C, D. When the host has turned on application cursor mode, ESC O A and so on. With a modifier, ESC [ 1 ; n A and so on, so Ctrl+Right is ESC [ 1 ; 5 C. Shift with an arrow on its own selects text instead, and sends nothing.
  • Home, End: ESC [ 1 ~ and ESC [ 4 ~. With a modifier, ESC [ 1 ; n H and ESC [ 1 ; n F.
  • Insert, Page Up, Page Down: ESC [ 2 ~, ESC [ 5 ~, ESC [ 6 ~
  • F1 to F4: ESC O P, Q, R, S
  • F5 to F12: ESC [ 15 ~, 17, 18, 19, 20, 21, 23, 24 followed by ~
  • Ctrl and a letter: the control character: Ctrl+A is 0x01 up to Ctrl+Z, 0x1A. Ctrl+V pastes instead, and Ctrl+C copies when text is selected.
  • Alt and a character: ESC followed by the character

The other Ctrl chords are Ctrl+Space, Ctrl+2 or Ctrl+@ (0x00), Ctrl+\ or Ctrl+4 (0x1C), Ctrl+] or Ctrl+5 (0x1D), Ctrl+6 or Ctrl+^ (0x1E), Ctrl+- or Ctrl+_ or Ctrl+/ or Ctrl+7 (0x1F), and Ctrl+8 or Ctrl+? (0x7F). To check that Ctrl+Space reaches a program on the host, see Ctrl+Space not working over SSH or in tmux: the NUL byte and how to test it.

A few app shortcuts such as Ctrl+, are also not sent: see VT220 and VT.

See what a key sends

On the host, run:

cat -v

Press a key and cat prints it with the escape character written as ^[. Pressing Home prints ^[[1~, and Ctrl+Right prints ^[[1;5C. Press Ctrl+D to end cat.

If a key does nothing

The app sends the bytes above. Whether a program acts on them depends on the host. A program that expects a different sequence for Home or End, or does not map Ctrl+Arrow or Ctrl+Backspace to word movement or deletion, ignores them or prints them. The fix is on the host, in the program's key bindings or the terminal type it uses.

Spotted a mistake? Email [email protected].