Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question really started from here. I would like to know why different terminals like rxvt and xterm use different values when mapping key combinations? Whilst I am in rxvt or xterm how can I find out the value of a key sequence and easily add this to the .inputrc file?

share|improve this question

For hysterical historical reasons. Hardware manufacturers didn't always standardize on common single control sequence for the same key, and neither did software writers when glass terminals were replaced by terminal emulators.

You can find out what control sequence a key generates in a particular terminal by typing Ctrl+V then the key (in most shells, or in the input of a command such as cat or hexdump). Most keys generate a control sequence consisting of the escape character followed by printable characters; the Ctrl+V causes the escape character to be inserted literally.

Fortunately, there are almost no conflicts among the control sequences sent by various terminals. The main exception is that some terminals send ^H for Backspace and ^? for Delete while others send ^? for Backspace and ^[[3~ for Delete. Many terminals have an option to switch between the two backspace/delete modes.

share|improve this answer
The correct spelling is "hystorical". ;) – ak2 Dec 5 '11 at 9:18

What Gilles said. As for the particular case being referred to, the VT100 and VT220 terminals (which is what today's terminal emulators try to emulate) didn't have keycodes for modifier+arrow key combinations, hence emulators introduced their own.

Not sure exactly why xterm and rxvt have different ones, but perhaps they were introduced independently at the same time. Actually xterm originally used shorter codes than it does today, but those caused problems so were changed eventually.

These days most terminal emulators, in particular the ones for the various desktop environments (including OS X), try to emulate xterm. Rxvt-unicode still carries on the rxvt tradition though.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.