Emacs Keys: Remap Key, translation-keymaps

By Xah Lee. Date: . Last updated: .

Swap Keys

Here's how to swap keys.

put this in your Emacs Init File:

;; swap keys
(keymap-set key-translation-map "<f11>" "<f12>")
(keymap-set key-translation-map "<f12>" "<f11>")

2011-03-17 thanks to Johan Bockgård

keyboard-translate

Note: there's the function keyboard-translate. However, it is designed to translate character only.

So, key combination isn't a character and you can't use it for Emacs Keys: Super Hyper key combination.

(Due to historical reasons, keyboard-translate does work for some Ctrl combination key. )

key-translate

2011-03-11 thanks to Stefan Monnier 〔http://www.iro.umontreal.ca/~monnier/〕 and Deniz Dogan for this tip. (http://groups.google.com/group/gnu.emacs.help/msg/e0dc12074c776bda)

Reference