@subsection Finding the keymap to use The list below describes step by step how Emacs finds a keymap from a given key sequence. As soon as a hit is found in any keymap (see @ref{Key Lookup}) then if the keymap entry is a function the search is over. However if the keymap entry is a variable symbol or a string then Emacs restarts with the variable symbol value or the string from FIRST-MAP. The keymap entry could also be a keymap. In that case the next event is looked up in that keymap. (But what happens if there is no hit there, I can not find any documentation on this???) @noindent @emph{Note 1:} When Emacs finally find a function symbol through this process it also checks for command remapping. This just replaces the function symbol with another. It is not recursive. @noindent @emph{Note 2:} You may find the function @code{current-active-maps} useful when looking into this. @table @asis @item START-HERE: First apply @code{extra-keyboard-modifiers} mask to each keyboard character read. @end table @itemize @bullet @item Each character read from the keyboard may be translated according to @code{keyboard-translate-table}. @item Characters that are self-inserting are translated according to @code{translation-table-for-input}. If a character is self-inserting then stop here. @item Translate meta characters according to @code{meta-prefix-char} to a two character sequence. @end itemize @table @asis @item FIRST-MAP: Look in @code{special-event-map}. @end table @itemize @bullet @item If using @code{read-from-minibuffer} (directly or indirectly) then look in the keymap given as parameter then look in this. Otherwise look in @code{minibuffer-local-map}. @item If using @code{read-no-blanks-input} to read from minibuffer then look in @code{minibuffer-local-ns-map} first and then @code{minibuffer-local-map}. @item If overriding-terminal-local-map look in this. Then go to GLOBAL. @item If overriding-local-map look in this. Then go to GLOBAL. @item Is there a "keymap" property of the text or overlay at point? @item Look for minor mode keymaps in @code{emulation-mode-map-alists}. @item Look for minor mode keymaps in @code{minor-mode-overriding-map-alist} @item Look for minor mode keymaps in @code{minor-mode-map-alist}. @item Is there a @code{local-map} property of the text or overlay at point? @item Is there a "local keymap" (those are for major modes)? @end itemize @table @asis @item GLOBAL: Look in the "current global keymap". (This is returned by @code{current-global-map} and may be different from @code{global-map}, see @code{use-global-map}.) @end table @itemize @bullet @item If it is an ASCII function key sequences then look in @code{function-key-map}. This map transforms to Emacs key sequences. @item The possibly transformed sequence after applying @code{function-key-map} is now handled to @code{key-translation-map} which works the same way. @item If any transformation was made by @code{function-key-map} or @code{key-translation-map} then take the new sequence and go back to FIRST-MAP. @end itemize