Taking control of your Mac keyboard

I’m very fond of my little Apple Bluetooth keyboard. Apart from the slightly ridiculous notion of having batteries in a peripheral device which never moves around, it does just what I need: full-size keys, with the cursor keys in a proper configuration, but no numeric keypad to make me stretch my wrist out to unusual angles when reaching for the mouse or trackpad.

However, there is one thing that bugs me. The Ctrl key is not in the bottom left corner where God intended Control keys to be! (Unless you worship the Sun god, in which case you may like your Control keys in the place more commonly used for Caps Lock.) But Sun worshippers, and others who do not consider the Caps Lock key to be evidence of intelligent design, can do something about it: in System Preferences you can remap your Caps Lock to do something useful, like control.

But I don’t think anybody, reaching for the Ctrl key, finds their fingers moving naturally towards the second key from the bottom-left.

Many MacBook Pros have the same layout.

For many Mac users this won’t be an issue, because the Cmd and Option/Alt keys are more important, but if you spend most of your time at the command line or in certain editors, you’ll be hitting the Fn key all the time, and inserting spurious characters into your text.

But today, I found one utility (and only one) that will let me remap the Fn key so it operates as Ctrl: the snappily-named KeyRemap4MacBook.

This offers a scary range of options to remap all sorts of things, but hidden in there is the one I needed:

Perfect. This makes the Fn key operate like the right-control key, which means I can do all those Emacs-y things like Ctrl-A to go to the beginning of the line, but interestingly it doesn’t change its effect on the function keys, so I can still use them to do Volume Up & Down etc.

Update: A little later I found that, while the volume keys worked without any further adjustment, some of the other top-row ones didn’t – in particular, the brightness controls. And, in fact, KeyRemap4MacBook comes with a better solution to my problem: there’s a single configuration under the ‘Change Fn Key’ settings that maps the Fn key to be Ctrl, and Alt-Fn to be Fn. Even better.

That was all I wanted, but I dug a little bit further and discovered that, if you’re willing to edit some XML configuration files, you can create your own arbitrary mappings.

As a programmer, I use # much more than I use £, but on the UK Apple keyboard, you have to press Alt-3 to get the #. So I wanted at least to swap with Shift-3, which is £.

Here’s the XML to do it:

<?xml version="1.0"?>
<root>
    <list>
        <item>
            <name>Swap £ and # on UK keyboard</name>
            <identifier>private.swap_pound_and_hash</identifier>
            <autogen>--KeyToKey-- KeyCode::KEY_3, ModifierFlag::SHIFT_L, 
                                        KeyCode::KEY_3, ModifierFlag::OPTION_L</autogen>
            <autogen>--KeyToKey-- KeyCode::KEY_3, ModifierFlag::OPTION_L, 
                                        KeyCode::KEY_3, ModifierFlag::SHIFT_L</autogen>
        </item>
    </list>
</root>

I may eventually put # on another key like, say, ‘§’. Who uses ‘§’ outside the publishing world, anyway?

Or – aha – perhaps that’s the best thing to do with CapsLock…

Update: If you use this keyboard with Linux, you might want to check out Phil Endecott’s page here.

Enjoyed this post? Why not sign up to receive Status-Q in your inbox?

4 Comments

Lawyers use the section mark (‘§’) quite a bit to cite the law.

Thinkpad’s have the Fn key as the low-left corner key. I’m rather glad that my new macbook pro has it that way, since I’m transitioning from a thinkpad.

Thanks very much. The fn key being where there ought to be a control key was driving me nuts. Not anymore.

Got Something To Say:

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

*

© Copyright Quentin Stafford-Fraser