Keypad Numeric Mode (DECKPNM)
Restore the numeric keypad to its default mode, where keys send their literal digits and operators.
- 0x1B
- ESC
- 0x3E
- >
Restores the numeric keypad to numeric mode. While this mode is set,
the keypad keys transmit their literal characters: digits 0-9, the
operators + - * / ., and a carriage return (\r) for Numpad Enter.
This is the inverse of Keypad Application Mode (DECKPAM) and is also the default state at terminal startup and after a hard reset (RIS) or soft reset (DECSTR).
Programs that enabled application keypad mode (typically full-screen TUIs
such as editors and pagers) must restore numeric mode before exiting,
otherwise the user's shell will see escape sequences instead of digits
when they press the keypad. Well-behaved curses applications send the
matching rmkx/smkx terminfo entries automatically.
Note
DECKPNM and the DEC private mode
?66(CSI ? 66 l) are equivalent. Resetting either one returns the keypad to numeric mode; setting either one switches to application mode.
DEC private mode 1035 (default on) causes Wintty to ignore the
application keypad request when the host treats NumLock as off. This
means a stale application-mode setting can be masked even without an
explicit DECKPNM, but you should not rely on that fallback. Always
restore numeric mode explicitly when your program no longer needs the
DEC private encoding.
Tip
If you observe a shell prompt where pressing keypad digits emits sequences like
Op,Oq,Or..., a previous program almost certainly exited without sending DECKPNM. Sendingprintf "\033>"interactively restores normal behavior.
printf "\033=" # enable application keypad mode first
printf "\033>" # restore numeric keypad mode
After the second sequence, pressing Numpad 5 should transmit the
literal byte 5 again rather than \033Ou. The internal keypad_keys
mode flag is now cleared.
printf "\033=" # enable application keypad mode
printf "\033c" # RIS - hard reset
After RIS, the keypad is back in numeric mode without any explicit DECKPNM, because numeric mode is the documented power-on default.