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,
- When I press the backtick key, emacs acts as if the Escape key were pressed.
- 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 )
(interactive)
(insert ?\`))
emacs -nw
but I guess there is more going on in a GUI Emacs: perhaps what's described in this answer.