Function: global-set-key
global-set-key is an interactive and byte-compiled function defined in
subr.el.gz.
Signature
(global-set-key KEY COMMAND)
Documentation
Give KEY a global binding as COMMAND.
This is a legacy function; see keymap-global-set for the
recommended function to use instead.
COMMAND is the command definition to use; usually it is a symbol naming an interactively-callable function. KEY is a key sequence; noninteractively, it is a string or vector of characters or event types, and non-ASCII characters with codes above 127 (such as ISO Latin-1) can be included if you use a vector.
Note that if KEY has a local binding in the current buffer, that local binding will continue to shadow any global binding that you make with this function.
Probably introduced at or before Emacs version 1.4.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
;;;; Key binding commands.
(defun global-set-key (key command)
"Give KEY a global binding as COMMAND.
This is a legacy function; see `keymap-global-set' for the
recommended function to use instead.
COMMAND is the command definition to use; usually it is
a symbol naming an interactively-callable function.
KEY is a key sequence; noninteractively, it is a string or vector
of characters or event types, and non-ASCII characters with codes
above 127 (such as ISO Latin-1) can be included if you use a vector.
Note that if KEY has a local binding in the current buffer,
that local binding will continue to shadow any global binding
that you make with this function."
(interactive
(let* ((menu-prompting nil)
(key (read-key-sequence "Set key globally: " nil t)))
(list key
(read-command (format "Set key %s to command: "
(key-description key))))))
(or (vectorp key) (stringp key)
(signal 'wrong-type-argument (list 'arrayp key)))
(define-key (current-global-map) key command))