Emacs: Key Notation: Return, Tab, Escape
2023-09-16 note: this page is obsolete. Emacs 29 (date 2023) has made many changes in key syntax.
<return> vs RET
"<return>" is the Return key while emacs runs in a graphical user interface.
"RET" is the Return key while emacs runs in a terminal.
"RET" is also equivalent to "C-m" (Ctrl+m). 〔see Emacs Key Notations Explained (/r, ^M, C-m, RET, <return>, M-, meta)〕
if you define:
(global-set-key (kbd "<return>") 'backward-char)
and run emacs in terminal, your keybinding will have no effect.
you need to use:
(global-set-key (kbd "RET") 'backward-char)
But the problem is, by binding (kbd "RET"), you are also binding (kbd "C-m"), regardless you run emacs in terminal or GUI.
<tab> vs TAB
"<tab>"is the notation for Tab key when emacs is run in graphical user interface. If you define a key with<tab>, it has no effect in terminal."TAB"is the notation for Tab key when emacs is run in terminal."TAB"is also equivalent to"C-i", in both graphical user interface and terminal. If you define key by"TAB", it also defines"C-i"(and vice versa), in both graphical user interface and terminal.
<escape> vs ESC
"<escape>"is the notation for Esc key when emacs is run in graphical user interface. If you define a key with<escape>, it won't have effect in terminal."ESC"is the notation for Esc key when emacs is run in terminal."ESC"is used in text terminal to communicate many special keys.- Also,
"ESC"is the same as"C-[".
WARNING:
Binding ESC may make arrow keys or f1 f2 keys not work, in text terminal, or in text terminal and running a remote emacs
because text terminal relies on escape sequence to represent those keys.