I am running emacs 24.3 through the terminal on OS X 10.8.4. I would like to modify the meta-key which is currently set to be the ESC key. I have successfully changed the meta-key from ESC to option/alt however I am interested in remapping the meta-key to be the left-shift key. As I never use the left-shift key, I wouldn't mind remapping it permanently for all applications on my machine.

  1. How can I change the meta-key in emacs running from the terminal to any other key?
  2. Specifically, I would like to change the meta-key to left-shift as this would be really close to where my fingers are usually placed.
  3. Can this be configured through emacs via emacs-lisp? Or, must this be configured through OS X settings such as how I changed the caps-lock key?

All help is greatly appreciated!

EDIT: How can I do this both on my mac and when I connect remotely?

  • 1
    For the purposes of seeing if we can provide a detailed solution, what key on the keyboard do you wish to map to be meta and what do you propose to do about the functionality that key would normally provide? My guess is you'd swap esc and this key, but I'd rather not guess if you have a preference in mind. – bmike Jun 13 '13 at 13:30
  • I would like the left-shift key which is right under caps-lock on my machine to function as the meta-key. Swapping them would be fine, but if you could tell me how to go about that process, that would be even better as I could experiment to see what I like best :) – CodeKingPlusPlus Jun 13 '13 at 19:05
  • 1
    Remapping keys (especially special keys) on a per-app basis isn't something the OS has a framework to provide, so you'll need a low level hack to accomplish the ideal choice. Would you be amenable to having the left shift key permanently reassigned? You might even be able to automate that, but I'd have to check on the ukulele users or download the latest version of that app to experiment. scripts.sil.org/cms/scripts/… – bmike Jun 13 '13 at 19:22
  • 1
    I would like the left shift key permanently reassigned. That sounds awesome! I'll look into it as well. – CodeKingPlusPlus Jun 13 '13 at 19:43
  • This post has a lot of information about [keyboard layouts][1]. [1]: apple.stackexchange.com/a/45402/33942 – Chauncey Garrett Jun 18 '13 at 21:35

Meta key problems with emacs seem to be very common, especially on OSX where alt/option is used to input special characters by default.

If you are using AquamacsEmacs[Aquamacs Homepage] or CarbonEmacsPackage, you may be able to set the modifier keys within your .emacs or other preferences file.

Specifically to map shift to meta, I'd try this (Note: this is untested):

(setq mac-shift-modifier 'meta)

If that doesn't work, there may not be an easy way to remap shift in this fashion. You may need to look into the define-key function in emacs lisp.

Otherwise, if you're using emacs via the terminal, from homebrew, or some port of xemacs with XQuartz, you might want to look into using xmodmap

  • `(setq mac-shift-modifier 'meta) does not work... – CodeKingPlusPlus Jun 24 '13 at 13:22

What about using a macro/hotkey program like Keyboard Maestro? (I have no affiliation with the program)

  • Keyboard Maestro doesn't provide triggers for modifier keys. – nohillside Jun 18 '13 at 18:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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