Kinds of User Input
===================

GNU Emacs is primarily designed for use with the keyboard.  While it is possible to use the mouse to issue editing commands through the menu bar and tool bar, that is not as efficient as using the keyboard. Therefore, this manual mainly documents how to edit with the keyboard.

Keyboard input into Emacs is based on a heavily-extended version of ASCII.  The simplest characters that you can input into Emacs correspond to graphic symbols such as a, B, 3, =, the space character (conventionally denoted as SPC), and so on.  Entering these using the keyboard is straightforward.  Certain characters found on non-English keyboards also fall into this category (see International).

In addition to these simple characters, Emacs recognizes control characters such as RET, TAB, DEL, ESC, F1, Home, left, etc.  Most keyboards have special keys for entering these.

Emacs also recognizes control characters that are entered using modifier keys.  Two commonly-used modifier keys are Control (which is usually labelled as Ctrl), and Meta (which is usually labeled as Alt) (We refer to Alt as Meta for historical reasons.).  For example, Control-a is entered by holding down the Ctrl key while pressing a; we will refer to this as C-a for short. Similarly Meta-a, or M-a for short, is entered by holding down the Alt key and pressing a.

You can also type Meta characters using two-character sequences starting with ESC.  Thus, you can enter M-a by typing ESC a.  You can enter C-M-a by typing ESC C-a.  Unlike Meta, ESC is entered as a separate character.  You don't hold down ESC while typing the next character; instead, press ESC and release it, then enter the next character.  This feature is useful on certain text-only terminals where the Meta key does not function reliably.

Modifier keys can apply not only to alphanumerical characters, but also to special input characters, such as the arrow keys and mouse buttons.

See Input Events (The Emacs Lisp Reference Manual), for the full Lisp-level details about keyboard and mouse input, which are collectively referred to as input events.  If you are not doing Lisp programming, but simply want to redefine the meaning of some characters or non-character events, see Customization.

On graphical displays, the window manager is likely to block the character M-TAB before Emacs can see it.  It may also block M-SPC, C-M-d and C-M-l.  If you have these problems, we recommend that you customize your window manager to turn off those commands, or put them on key combinations that Emacs does not use.

Keys
====

Some Emacs commands are invoked by just one input event; for example, C-f moves forward one character in the buffer.  But Emacs also has commands that take two or more input events to invoke, such as C-x C-f and C-x 4 C-f.

A key sequence, or key for short, is a sequence of one or more input events that is meaningful as a unit.  If a key sequence invokes a command, we call it a complete key; for example, C-f, C-x C-f and C-x 4 C-f are all complete keys. If a key sequence isn't long enough to invoke a command, we call it a prefix key; from the preceding example, we see that C-x and C-x 4 are prefix keys.  Every key is either a complete key or a prefix key.

A prefix key combines with the following input event to make a longer key sequence, which may itself be complete or a prefix.  For example, C-x is a prefix key, so C-x and the next input event combine to make a two-event key sequence.  This two-event key sequence could itself be a prefix key (such as C-x 4), or a complete key (such as C-x C-f).  There is no limit to the length of a key sequence, but in practice people rarely use sequences longer than three or four input events.

You can't add input events onto a complete key.  For example, the two-event sequence C-f C-k is not a key, because the C-f is a complete key in itself, so C-f C-k cannot have an independent meaning as a command.  C-f C-k is two key sequences, not one.

By default, the prefix keys in Emacs are C-c, C-h, C-x, C-x RET, C-x @, C-x a, C-x n, C-x r, C-x v, C-x 4, C-x 5, C-x 6, ESC, M-g, and M-o.  (F1 and F2 are aliases for C-h and C-x 6.)  This list is not cast in stone; if you customize Emacs, you can make new prefix keys.  You could even eliminate some of the standard ones, though this is not recommended for most users; for example, if you remove the prefix definition of C-x 4, then C-x 4 ANYTHING would become an invalid key sequence.  See Key Bindings.

Typing the help character (C-h or F1) after a prefix key displays a list of the commands starting with that prefix.  The sole exception to this rule is ESC: ESCC-h is equivalent to C-M-h, which does something else entirely.  You can, however, use F1 to displays a list of the commands starting with ESC.

Keys and Commands
=================

This manual is full of passages that tell you what particular keys do.  But Emacs does not assign meanings to keys directly.  Instead, Emacs assigns meanings to named commands, and then gives keys their meanings by binding them to commands.

Every command has a name chosen by a programmer.  The name is usually made of a few English words separated by dashes; for example, next-line or forward-word.  A command also has a function definition which is a Lisp program; this is how the command does its work.  In Emacs Lisp, a command is a Lisp function with special properties that make it suitable for interactive use. For more information on commands and functions, see What Is a Function (The Emacs Lisp Reference Manual).

The bindings between keys and commands are recorded in tables called keymaps.  See Keymaps.

When we say that ``C-n moves down vertically one line'' we are glossing over a subtle distinction that is irrelevant in ordinary use, but vital for Emacs customization.  The command next-line does a vertical move downward.  C-n has this effect because it is bound to next-line.  If you rebind C-n to the command forward-word, C-n will move forward one word instead.

In this manual, we will often speak of keys like C-n as commands, even though strictly speaking the key is bound to a command. Usually we state the name of the command which really does the work in parentheses after mentioning the key that runs it.  For example, we will say that ``The command C-n (next-line) moves point vertically down,'' meaning that the command next-line moves vertically down, and the key C-n is normally bound to it.

Since we are discussing customization, we should tell you about variables.  Often the description of a command will say, ``To change this, set the variable mumble-foo.''  A variable is a name used to store a value.  Most of the variables documented in this manual are meant for customization: some command or other part of Emacs examines the variable and behaves differently according to the value that you set.  You can ignore the information about variables until you are interested in customizing them.  Then read the basic information on variables (see Variables) and the information about specific variables will make sense.