GNU Emacs Manual - User Input

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

## Kinds of User Input

GNU Emacs uses an extension of the ASCII character set for keyboard input; it also accepts non-character input events including function keys and mouse button actions.

ASCII consists of 128 character codes. Some of these codes are assigned graphic symbols such as ``a'` and ``='`; the rest are control characters, such as `Control-a` (usually written `C-a` for short). `C-a` gets its name from the fact that you type it by holding down the `CTRL` key while pressing `a`.

Some ASCII control characters have special names, and most terminals have special keys you can type them with: for example, `RET`, `TAB`, `DEL` and `ESC`. The space character is usually referred to below as `SPC`, even though strictly speaking it is a graphic character whose graphic happens to be blank. Some keyboards have a key labeled "linefeed" which is an alias for `C-j`.

Emacs extends the ASCII character set with thousands more printing characters (see section International Character Set Support), additional control characters, and a few more modifiers that can be combined with any character.

On ASCII terminals, there are only 32 possible control characters. These are the control variants of letters and ``@[]\^_'`. In addition, the shift key is meaningless with control characters: `C-a` and `C-A` are the same character, and Emacs cannot distinguish them.

But the Emacs character set has room for control variants of all printing characters, and for distinguishing between `C-a` and `C-A`. X Windows makes it possible to enter all these characters. For example, `C--` (that's Control-Minus) and `C-5` are meaningful Emacs commands under X.

Another Emacs character-set extension is additional modifier bits. Only one modifier bit is commonly used; it is called Meta. Every character has a Meta variant; examples include `Meta-a` (normally written `M-a`, for short), `M-A` (not the same character as `M-a`, but those two characters normally have the same meaning in Emacs), `M-`RET``, and `M-C-a`. For reasons of tradition, we usually write `C-M-a` rather than `M-C-a`; logically speaking, the order in which the modifier keys `CTRL` and `META` are mentioned does not matter.

Some terminals have a `META` key, and allow you to type Meta characters by holding this key down. Thus, `Meta-a` is typed by holding down `META` and pressing `a`. The `META` key works much like the `SHIFT` key. Such a key is not always labeled `META`, however, as this function is often a special option for a key with some other primary purpose.

If there is no `META` key, you can still type Meta characters using two-character sequences starting with `ESC`. Thus, to enter `M-a`, you could type ``ESC` a`. To enter `C-M-a`, you would type ``ESC` C-a`. `ESC` is allowed on terminals with `META` keys, too, in case you have formed a habit of using it. X Windows provides several other modifier keys that can be applied to any input character. These are called `SUPER`, `HYPER` and `ALT`. We write ``s-'`, ``H-'` and ``A-'` to say that a character uses these modifiers. Thus, `s-H-C-x` is short for `Super-Hyper-Control-x`. Not all X terminals actually provide keys for these modifier flags--in fact, many terminals have a key labeled `ALT` which is really a `META` key. The standard key bindings of Emacs do not include any characters with these modifiers. But you can assign them meanings of your own by customizing Emacs.

Keyboard input includes keyboard keys that are not characters at all: for example function keys and arrow keys. Mouse buttons are also outside the gamut of characters. You can modify these events with the modifier keys `CTRL`, `META`, `SUPER`, `HYPER` and `ALT`, just like keyboard characters.

Input characters and non-character inputs are collectively called input events. See section `Input Events' in The Emacs Lisp Reference Manual, for more information. If you are not doing Lisp programming, but simply want to redefine the meaning of some characters or non-character events, see section Customization.

ASCII terminals cannot really send anything to the computer except ASCII characters. These terminals use a sequence of characters to represent each function key. But that is invisible to the Emacs user, because the keyboard input routines recognize these special sequences and convert them to function key events before any other part of Emacs gets to see them.

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