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 (if overriding-terminal-local-map
(find-in overriding-terminal-local-map)
(if overriding-local-map
(find-in overriding-local-map)
(or (find-in (get-char-property (point) 'keymap))
(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)))
The 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,
or a symbolic prefix event followed by 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.
self-insert-command are translated
according to translation-table-for-input before insertion.
current-active-maps returns a list of the
currently active keymaps at point.