diff options
Diffstat (limited to 'devdocs/elisp/keyboard-events.html')
| -rw-r--r-- | devdocs/elisp/keyboard-events.html | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/devdocs/elisp/keyboard-events.html b/devdocs/elisp/keyboard-events.html new file mode 100644 index 00000000..ba011f45 --- /dev/null +++ b/devdocs/elisp/keyboard-events.html @@ -0,0 +1,11 @@ + <h4 class="subsection">Keyboard Events</h4> <p>There are two kinds of input you can get from the keyboard: ordinary keys, and function keys. Ordinary keys correspond to (possibly modified) characters; the events they generate are represented in Lisp as characters. The event type of a <em>character event</em> is the character itself (an integer), which might have some modifier bits set; see <a href="classifying-events">Classifying Events</a>. </p> <p>An input character event consists of a <em>basic code</em> between 0 and 524287, plus any or all of these <em>modifier bits</em>: </p> <dl compact> <dt>meta</dt> <dd> +<p>The 2**27 bit in the character code indicates a character typed with the meta key held down. </p> </dd> <dt>control</dt> <dd> +<p>The 2**26 bit in the character code indicates a non-<acronym>ASCII</acronym> control character. </p> <p><small>ASCII</small> control characters such as <kbd>C-a</kbd> have special basic codes of their own, so Emacs needs no special bit to indicate them. Thus, the code for <kbd>C-a</kbd> is just 1. </p> <p>But if you type a control combination not in <acronym>ASCII</acronym>, such as <kbd>%</kbd> with the control key, the numeric value you get is the code for <kbd>%</kbd> plus 2**26 (assuming the terminal supports non-<acronym>ASCII</acronym> control characters), i.e. with the 27th bit set. </p> </dd> <dt>shift</dt> <dd> +<p>The 2**25 bit (the 26th bit) in the character event code indicates an <acronym>ASCII</acronym> control character typed with the shift key held down. </p> <p>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 <acronym>ASCII</acronym> character set whenever possible, Emacs avoids using the 2**25 bit for those character events. </p> <p>However, <acronym>ASCII</acronym> provides no way to distinguish <kbd>C-A</kbd> from <kbd>C-a</kbd>, so Emacs uses the 2**25 bit in <kbd>C-A</kbd> and not in <kbd>C-a</kbd>. </p> </dd> <dt>hyper</dt> <dd> +<p>The 2**24 bit in the character event code indicates a character typed with the hyper key held down. </p> </dd> <dt>super</dt> <dd> +<p>The 2**23 bit in the character event code indicates a character typed with the super key held down. </p> </dd> <dt>alt</dt> <dd><p>The 2**22 bit in the character event code indicates a character typed with the alt key held down. (The key labeled <tt class="key">Alt</tt> on most keyboards is actually treated as the meta key, not this.) </p></dd> </dl> <p>It is best to avoid mentioning specific bit numbers in your program. To test the modifier bits of a character, use the function <code>event-modifiers</code> (see <a href="classifying-events">Classifying Events</a>). When making key bindings, you can use the read syntax for characters with modifier bits (‘<samp>\C-</samp>’, ‘<samp>\M-</samp>’, and so on). For making key bindings with <code>define-key</code>, you can use lists such as <code>(control hyper ?x)</code> to specify the characters (see <a href="changing-key-bindings">Changing Key Bindings</a>). The function <code>event-convert-list</code> converts such a list into an event type (see <a href="classifying-events">Classifying Events</a>). </p><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Keyboard-Events.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Keyboard-Events.html</a> + </p> +</div> |
