I'm using Emacs 27.2 (2021-07-22) and for years have mapped Escape to Backtick key (Ok, I did this after the industry moved the Escape key to the location it is in now, next to F1).

The keyboard I have matches this diagram:

The lisp code I use to do the swapping is:

(keyboard-translate ?\` ?\e)  ; Make backquote behave as escape
(keyboard-translate ?\e ?\`)  ; Make escape work as backtick // THIS DOESN'T WORK

This works for the backtick, but doesn't change the mapping for the escape key.

After the above,

  1. When I press the backtick key, emacs acts as if the Escape key were pressed.
  2. When I press the Escape key, emacs acts as if the Escape key were pressed.

What is the right way to swap the Escape and Backtick keys? Only inside of emacs. Also, I don't want to remap my keyboard in my Windows or Linux OS, I've done this in the past and it causes problems with KVMs (mostly this was with mapping CapsLock to Control).

NOTE: My work around is to define a function to insert a backtick and map that to another key sequence.

(defun insert-backtick (&optional arg )
  (insert ?\`))
  • 1
    It works in emacs -nw but I guess there is more going on in a GUI Emacs: perhaps what's described in this answer.
    – NickD
    Commented Mar 14, 2023 at 21:02

1 Answer 1


The ESC key has along with C- and M- in Emacs the special status of being a prefix key, so that the translation from key to key does not work.

Check out: How to remove bindings to the ESC prefix key and try:

(define-key key-translation-map (kbd "ESC") (kbd "`"))

( tested to work OK with Emacs 29 on Linux Mint 21 Cinnamon )

I assume that this above takes directly the keypress to re-map it instead of 'waiting' for a key code resulting from an interpreted keypress-combination.

  • This worked, however, it also caused Esc+Backspace to stop working. The Esc+Backspace key sequence was bound to backward-kill-word before applying the solution (define-key key-translation-map (kbd "ESC") (kbd "`")) . After applying the solution, all of the multi-key combinations involving escape Esc+ANYKEY stopped working, so while this did answer my question, I need to ask another question on how to keep all of the multi-key sequences when remaping the ESC key.
    – PatS
    Commented Mar 22, 2023 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.