Keypad Application Mode (DECKPAM)

Switch the numeric keypad into application mode so its keys send DEC private escape sequences instead of literal digits.

  1. 0x1B
    ESC
  2. 0x3D
    =

Switches the numeric keypad into application mode. While this mode is set, pressing a keypad key sends a DEC private escape sequence of the form ESC O x (where x identifies the specific key) instead of the literal digit, operator, or Enter byte.

This is the inverse of Keypad Numeric Mode (DECKPNM), which restores the default behavior where the keypad sends literal characters.

Encoded sequences

In application mode, the keypad sends the following sequences:

KeySequence
Numpad 0-9ESC O p through ESC O y
Numpad .ESC O n
Numpad /ESC O o
Numpad *ESC O j
Numpad -ESC O m
Numpad +ESC O k
Numpad EnterESC O M

In numeric mode (the default and the state after a terminal reset), the same keys send their literal characters (e.g. keypad 5 sends 5, keypad Enter sends \r).

Note

DECKPAM and the DEC private mode ?66 (CSI ? 66 h / CSI ? 66 l) are two ways to control the same internal state. Setting either one enables application keypad mode; resetting either one disables it.

Interaction with NumLock and DEC mode 1035

On real PCs, the keypad doubles as a cursor pad when NumLock is off. xterm exposes this through DEC private mode 1035 (default on), which causes the terminal to ignore the application keypad request whenever the host treats NumLock as off. The effect is that programs which call DECKPAM still get numeric-style behavior unless the user explicitly disables mode 1035 with CSI ? 1035 l.

Tip

Most modern full-keyboards do not surface a NumLock state to the terminal at all, so mode 1035 rarely matters in practice. Wintty honors mode 1035 for compatibility with terminfo entries that assume xterm semantics.

Validation

DECKPAM V-1: Enables application keypad mode

printf "\033="

After this sequence, pressing Numpad 5 should transmit \033Ou instead of the literal 5. The keypad mode flag is now set; running infocmp -L on the local terminfo entry and consulting the application_keypad_mode capability shows the same ESC = sequence the program just sent.