emacs Basic Keybindings Key bindings notation


Example

Emacs' documentation uses a consistent notation for all key bindings, which is explained here:

Key chords

A "key chord" is obtained by pressing two or more keys simultaneously. Key chords are denoted by separating all keys by dashes (-). They usually involve modifier keys, which are put up front:

  • C-: control;
  • S-: shift;
  • M-: alt (the "M" stands for "Meta" for historical reasons).

Other keys are simply denoted by their name, like:

  • a: the a key;
  • left: the left arrow key;
  • SPC: the space key;
  • RET: the return key.

Examples of key chords thus include:

  • C-a: pressing control and a simultaneously;
  • S-right: pressing shift and right simultaneously;
  • C-M-a: pressing control, alt and a simultaneously.

Key sequences

"Key sequences" are sequences of keys (or key chords), which must be typed one after the other. They are denoted by separating all key (or chord) notations by a space.

Examples include:

  • C-x b: pressing control and x simultaneously, then releasing them and pressing b;
  • C-x C-f: pressing control and x simultaneously, then releasing x and pressing f (since both chords involve the control modifier, it is not necessary to release it).

Using ESC instead of Alt

Key chords using the Alt modifier can also be entered as a key sequence starting with ESC. This can be useful when using Emacs over a remote connection that does not transmit Alt key chords, or when these key combinations are captured e.g by a window manager.

Example:

M-x can be entered as ESC x.

Describing key bindings in Emacs lisp files

The same notation that is described here can be used when defining key bindings in Emacs lisp files.

Example:

(global-set-key (kbd "C-x C-b") 'buffer-menu)
binds the key sequence C-x C-b to the command buffer-menu