A Hyper Key for the Mac

The other day I wrote about using the Mac's virtual keypad to get some additional key sequences for Emacs. That didn't work out as well as I'd hoped because, unlike my MacBook Pro, the keyboard for my iMac doesn't have a virtual keypad. I thought about getting an add-on Bluetooth keypad for my iMac but that seemed like unnecessary expense and clutter for something that I might not use all that much.

All was not lost, though, because Magnar Sveen popped up in the comments to suggest that I map the 【fn】key to 【hyper】. I'd considered doing that before but the 【fn】 key is used to control music functions such as start/stop and volume and I sometimes want to use those functions while I'm in Emacs. Sveen replied that if you map 【fn】 to 【hyper】 it will still work properly when you use it to modify a function key, which is where the music controls are.

So, this is a note to all Emacs users working on a Mac. Just map 【fn】 to 【hyper】 and you have the best of both worlds: easy access to all the controls living on the function keys and an easy-to-use 【hyper】 key that opens up a bunch of key sequences that you can map to your favorite commands. I implemented it by adding

(setq ns-function-modifier 'hyper)

to my darwin.el file, which is where all my Mac specific configurations live.

Thanks to Magnar for setting me straight on this. I'm already loving having the 【hyper】 key in an easy to use place.

This entry was posted in General and tagged . Bookmark the permalink.
  • Josh Tolle

    If for whatever reason there are issues with using the built-in volume controls while in Emacs, you can write some AppleScript to handle your volume and bind keys to call the scripts.

    • jcs

      Good point but happily everything works perfectly after I mapped fn to hyper.

  • jney

    i used to use while on mac.
    is it possible on linux ?

  • Phil Hudson

    Anyone got a recipe for mapping a hyper key *in X11* using a Mac keyboard without a fn key?

    (I run MacPorts' X11 build of emacs rather than the standard Mac build in order to keep my usage patterns as similar as possible to what they are in linux and Cygwin.)