[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are two kinds of input you can get from the keyboard: ordinary keys, and function keys. Ordinary keys correspond to characters; the events they generate are represented in Lisp as characters. The event type of a character event is the character itself (an integer); see 21.6.12 Classifying Events.
An input character event consists of a basic code between 0 and 524287, plus any or all of these modifier bits:
ASCII control characters such as C-a have special basic codes of their own, so Emacs needs no special bit to indicate them. Thus, the code for C-a is just 1.
But if you type a control combination not in ASCII, such as % with the control key, the numeric value you get is the code for % plus 2**26 (assuming the terminal supports non-ASCII control characters).
For letters, the basic code itself indicates upper versus lower case; for digits and punctuation, the shift key selects an entirely different character with a different basic code. In order to keep within the ASCII character set whenever possible, Emacs avoids using the 2**25 bit for those characters.
However, ASCII provides no way to distinguish C-A from C-a, so Emacs uses the 2**25 bit in C-A and not in C-a.
It is best to avoid mentioning specific bit numbers in your program.
To test the modifier bits of a character, use the function
event-modifiers
(see section 21.6.12 Classifying Events). When making key
bindings, you can use the read syntax for characters with modifier bits
(`\C-', `\M-', and so on). For making key bindings with
define-key
, you can use lists such as (control hyper ?x)
to
specify the characters (see section 22.9 Changing Key Bindings). The function
event-convert-list
converts such a list into an event type
(see section 21.6.12 Classifying Events).
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |