GNU Emacs використовує розширення набору символів ASCII для введення з клавіатури. Він також сприймає несимвольні події, наприклад, натискання функціональних клавіш, як також події від кнопок миші.
ASCII складається зі 128 символьних кодів. Деяким із цих кодів призначено графічні символи, як-от a
чи =
; решта — це керівні символи, наприклад, Control-a
(для скорочення його зазвичай записують як C-a
). C-a
має таку назву, оскільки для того, щоб його набрати, потрібно, втримуючи клавішу <CTRL>
, натиснути клавішу <a>
.
Деякі керівні символи ASCII мають особливі назви, й більшість терміналів мають клавіші, котрими ці символи можна вводити: наприклад, <RET>
, <TAB>
, <DEL>
та <ESC>
.
The space character is usually referred to below as , 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 (*note International::), 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'.
The X Window System 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 and are mentioned does not matter.
Some terminals have a 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 key works much like
the key. Such a key is not always labeled , however, as
this function is often a special option for a key with some other
primary purpose. Sometimes it is labeled or ; on a Sun
keyboard, it may have a diamond on it.
If there is no key, you can still type Meta characters using
two-character sequences starting with . Thus, you can enter M-a'
by typing
a'. You can enter C-M-a' by typing
C-a'.
is allowed on terminals with keys, too, in case you have
formed a habit of using it.
The X Window System provides several other modifier keys that can be
applied to any input character. These are called , and
. 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 which is really a
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 , , , and , just like keyboard characters.
Input characters and non-character inputs are collectively called "input events". *Note Input Events: (elisp)Input Events, 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
- Note 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.