KeyRemap4MacBook

Submitted by Bill St. Clair on Tue, 16 Aug 2011 03:50:01 GMT  <== Lisp ==> 

I spend most of my days in Emacs, writing Lisp. So I use the "control" and "meta" keys all the time. I map meta to the Mac "command" key with a setting in my "~/.emacs" file:

  (setq mac-command-modifier 'meta
        mac-option-modifier nil)
My new Apple wireless keyboard has a "fn" key in the lower left-hand corner of the keyboard, with the "control" key next to it. Most distressing, since my left pinky is accustomed to finding the "control" key in the lower left-hand corner. I knew this before I got this keyboard, and would have gotten the wired keyboard with the numeric keypad had I not had a solution in mind. Enter KeyRemap4MacBook, a System Preferences panel that allows you to remap just about any key to just about any other key. It has a setting that maps "fn" to "control" only when a letter is pressed. This allows "fn" to be used normally on the top row of keys, but makes it function fine as emacs "control" when you need it. Almost. The one problem with the built-in key mapping is that it doesn't map <fn>-space to <control>-space. I type that pretty often, and moving my pinky over to the "control" key to do so is a real pain. Fortunately, KeyRemap4MacBook is open source, and you can customize it by adding XML to "~/Library/Application Support/KeyRemap4MacBook/private.xml". I found the source for the built-in XML settings, looked through that for "Fn+letter to Control_L+letter", add a setting to private.xml containing a single key mapping:

          --KeyToKey-- KeyCode::SPACE, ModifierFlag::FN, KeyCode::SPACE, ModifierFlag::CONTROL_L

Presto, <fn>-space sets the mark.

Here's my private.xml. To use it, install KeyRemap4MacBook, which requires a restart of your computer. save the file as "~/Library/Application Support/KeyRemap4MacBook/private.xml", in the KeyRemap4MacBook preference pane, press the "ReloadXML" button, then check "Fn+space+ to Control_L+space+".

KeyRemap4MacBook settings

Add comment Edit post Add post

Comments (3):

I changed my private.xml

Submitted by Bill St. Clair on Tue, 16 Aug 2011 10:38:09 GMT

I changed my private.xml to contain only the single fn+space to control-L+space mapping, and use the built-in fn+letter to control-L+letter with it. File at link updated and screen shot added.

Edit comment

fn key

Submitted by Underground Carpenter on Tue, 16 Aug 2011 10:42:37 GMT

Hi Bill,

I've been using a Mac since the mid 80's. I bought one of the first "Fat Macs", with an astounding 500k of RAM. The world was mine and I was drunk with power!

I never noticed when Apple first put that "fn" key on the keyboard, but I'm looking at it now and wondering what the hell it does. So I'm off to discover new worlds.

I like your Captcha. It's much easier than the distorted word verifications everybody else has. (Damn! Is that a "z" or a "j"?)

Dave

Edit comment

So far, the new captcha

Submitted by Bill St. Clair on Tue, 16 Aug 2011 10:59:10 GMT

So far, the new captcha has stopped more spam than the old one ever did. I'm getting a trickle, but I used to get 10-20 spams a day. I've also gotten a couple of spam registrations. If these increase, I'll have to moderate registration, too. Hope it isn't necessary.

Edit comment