After translation of event subsequences (see Translation Keymaps) Emacs looks for them in the active keymaps. Here is a pseudo-Lisp description of the order and conditions for searching them:
(or (cond (overriding-terminal-local-map (find-in overriding-terminal-local-map)) (overriding-local-map (find-in overriding-local-map)) ((or (find-in (get-char-property (point) 'keymap)) (find-in temp-map) (find-in-any emulation-mode-map-alists) (find-in-any minor-mode-overriding-map-alist) (find-in-any minor-mode-map-alist) (if (get-text-property (point) 'local-map) (find-in (get-char-property (point) 'local-map)) (find-in (current-local-map)))))) (find-in (current-global-map)))
find-in and find-in-any are pseudo functions that search
in one keymap and in an alist of keymaps, respectively. (Searching a
single keymap for a binding is called key lookup; see Key Lookup.) If the key sequence starts with a mouse event, that event's position
is used instead of point and the current buffer. Mouse events on an
embedded string use non-
nil text properties from that string
instead of the buffer. temp-map is a pseudo variable that
represents the effect of a
When a match is found (see Key Lookup), if the binding in the keymap is a function, the search is over. However if the keymap entry is a symbol with a value or a string, Emacs replaces the input key sequences with the variable's value or the string, and restarts the search of the active keymaps.
The function finally found might also be remapped. See Remapping Commands.