Go to the first, previous, next, last section, table of contents.


Keyboard Translations

Some keyboards do not make it convenient to send all the special characters that Emacs uses. The most common problem case is the DEL character. Some keyboards provide no convenient way to type this very important character--usually because they were designed to expect the character C-h to be used for deletion. On these keyboards, if you press the key normally used for deletion, Emacs handles the C-h as a prefix character and offers you a list of help options, which is not what you want.

You can work around this problem within Emacs by setting up keyboard translations to turn C-h into DEL and DEL into C-h, as follows:

;; Translate C-h to DEL.
(keyboard-translate ?\C-h ?\C-?)

;; Translate DEL to C-h.
(keyboard-translate ?\C-? ?\C-h)

Keyboard translations are not the same as key bindings in keymaps (see section Keymaps). Emacs contains numerous keymaps that apply in different situations, but there is only one set of keyboard translations, and it applies to every character that Emacs reads from the terminal. Keyboard translations take place at the lowest level of input processing; the keys that are looked up in keymaps contain the characters that result from keyboard translation.

Under X, the keyboard key named DELETE is a function key and is distinct from the ASCII character named DEL. See section Named ASCII Control Characters. Keyboard translations affect only ASCII character input, not function keys; thus, the above example used under X does not affect the DELETE key. However, the translation above isn't necessary under X, because Emacs can also distinguish between the BACKSPACE key and C-h; and it normally treats BACKSPACE as DEL.

For full information about how to use keyboard translations, see section `Translating Input' in The Emacs Lisp Reference Manual.


Go to the first, previous, next, last section, table of contents.