summaryrefslogtreecommitdiff
path: root/devdocs/elisp/event-mod.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/elisp/event-mod.html')
-rw-r--r--devdocs/elisp/event-mod.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/devdocs/elisp/event-mod.html b/devdocs/elisp/event-mod.html
new file mode 100644
index 00000000..c7a3e487
--- /dev/null
+++ b/devdocs/elisp/event-mod.html
@@ -0,0 +1,23 @@
+ <h4 class="subsection">Modifying and Translating Input Events</h4> <p>Emacs modifies every event it reads according to <code>extra-keyboard-modifiers</code>, then translates it through <code>keyboard-translate-table</code> (if applicable), before returning it from <code>read-event</code>. </p> <dl> <dt id="extra-keyboard-modifiers">Variable: <strong>extra-keyboard-modifiers</strong>
+</dt> <dd>
+<p>This variable lets Lisp programs “press” the modifier keys on the keyboard. The value is a character. Only the modifiers of the character matter. Each time the user types a keyboard key, it is altered as if those modifier keys were held down. For instance, if you bind <code>extra-keyboard-modifiers</code> to <code>?\C-\M-a</code>, then all keyboard input characters typed during the scope of the binding will have the control and meta modifiers applied to them. The character <code>?\C-@</code>, equivalent to the integer 0, does not count as a control character for this purpose, but as a character with no modifiers. Thus, setting <code>extra-keyboard-modifiers</code> to zero cancels any modification. </p> <p>When using a window system, the program can press any of the modifier keys in this way. Otherwise, only the <tt class="key">CTL</tt> and <tt class="key">META</tt> keys can be virtually pressed. </p> <p>Note that this variable applies only to events that really come from the keyboard, and has no effect on mouse events or any other events. </p>
+</dd>
+</dl> <dl> <dt id="keyboard-translate-table">Variable: <strong>keyboard-translate-table</strong>
+</dt> <dd>
+<p>This terminal-local variable is the translate table for keyboard characters. It lets you reshuffle the keys on the keyboard without changing any command bindings. Its value is normally a char-table, or else <code>nil</code>. (It can also be a string or vector, but this is considered obsolete.) </p> <p>If <code>keyboard-translate-table</code> is a char-table (see <a href="char_002dtables">Char-Tables</a>), then each character read from the keyboard is looked up in this char-table. If the value found there is non-<code>nil</code>, then it is used instead of the actual input character. </p> <p>Note that this translation is the first thing that happens to a character after it is read from the terminal. Record-keeping features such as <code>recent-keys</code> and dribble files record the characters after translation. </p> <p>Note also that this translation is done before the characters are supplied to input methods (see <a href="input-methods">Input Methods</a>). Use <code>translation-table-for-input</code> (see <a href="translation-of-characters">Translation of Characters</a>), if you want to translate characters after input methods operate. </p>
+</dd>
+</dl> <dl> <dt id="keyboard-translate">Function: <strong>keyboard-translate</strong> <em>from to</em>
+</dt> <dd><p>This function modifies <code>keyboard-translate-table</code> to translate character code <var>from</var> into character code <var>to</var>. It creates the keyboard translate table if necessary. </p></dd>
+</dl> <p>Here’s an example of using the <code>keyboard-translate-table</code> to make <kbd>C-x</kbd>, <kbd>C-c</kbd> and <kbd>C-v</kbd> perform the cut, copy and paste operations: </p> <div class="example"> <pre class="example">(keyboard-translate ?\C-x 'control-x)
+(keyboard-translate ?\C-c 'control-c)
+(keyboard-translate ?\C-v 'control-v)
+(global-set-key [control-x] 'kill-region)
+(global-set-key [control-c] 'kill-ring-save)
+(global-set-key [control-v] 'yank)
+</pre>
+</div> <p>On a graphical terminal that supports extended <acronym>ASCII</acronym> input, you can still get the standard Emacs meanings of one of those characters by typing it with the shift key. That makes it a different character as far as keyboard translation is concerned, but it has the same usual meaning. </p> <p>See <a href="translation-keymaps">Translation Keymaps</a>, for mechanisms that translate event sequences at the level of <code>read-key-sequence</code>. </p><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 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/Event-Mod.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Event-Mod.html</a>
+ </p>
+</div>