49.3.8 Rebinding Function Keys
Key sequences can contain function keys as well as ordinary characters. Just as Lisp characters (actually integers) represent keyboard characters, Lisp symbols represent function keys. If the function key has a word as its label, then that word is also the name of the corresponding Lisp symbol. Here are the conventional Lisp names for common function keys:
left
, up
, right
, down
β
Cursor arrow keys.
begin
, end
, home
, next
, prior
β
Other cursor repositioning keys.
select
, print
, execute
, backtab
β
insert
, undo
, redo
, clearline
β
insertline
, deleteline
, insertchar
, deletechar
β
Miscellaneous function keys.
f1
, f2
, β¦ f35
β
Numbered function keys (across the top of the keyboard).
kp-add
, kp-subtract
, kp-multiply
, kp-divide
β
kp-backtab
, kp-space
, kp-tab
, kp-enter
β
kp-separator
, kp-decimal
, kp-equal
β
kp-prior
, kp-next
, kp-end
, kp-home
β
kp-left
, kp-up
, kp-right
, kp-down
β
kp-insert
, kp-delete
β
Keypad keys (to the right of the regular keyboard), with names or punctuation.
kp-0
, kp-1
, β¦ kp-9
β
Keypad keys with digits.
kp-f1
, kp-f2
, kp-f3
, kp-f4
β
Keypad PF keys.
These names are conventional, but some systems (especially when using X) may use different names. To make certain what symbol is used for a given function key on your terminal, type C-h c
followed by that key.
See Init Rebinding, for examples of binding function keys.
Many keyboards have a numeric keypad on the right-hand side. The numeric keys in the keypad double up as cursor motion keys, toggled by a key labeled βNum Lock
β. By default, Emacs translates these keys to the corresponding keys on the main keyboard. For example, when βNum Lock
β is on, the key labeled β8
β on the numeric keypad produces kp-8
, which is translated to 8
; when βNum Lock
β is off, the same key produces kp-up
, which is translated to UP
. If you rebind a key such as 8
or UP
, it affects the equivalent keypad key too. However, if you rebind a βkp-
β key directly, that wonβt affect its non-keypad equivalent. Note that the modified keys are not translated: for instance, if you hold down the Meta
key while pressing the β8
β key on the numeric keypad, that generates M-kp-8
.
Emacs provides a convenient method for binding the numeric keypad keys, using the variables keypad-setup
, keypad-numlock-setup
, keypad-shifted-setup
, and keypad-numlock-shifted-setup
. These can be found in the βkeyboard
β customization group (see Easy Customization). You can rebind the keys to perform other tasks, such as issuing numeric prefix arguments.