P16: a blog by Matt Kangas home archive
03 Jun 2009

Mac users: Switch "Spaces" using F1-F4 keys

Hola! It's been a while since I've posted anything here. Since January I've been largely occupied with:

I plan to write about those topics... well, soon. :) Today, I just have a tip for Mac folks who use Leopard's "Spaces" feature.

Switch directly to a "Space" using function keys

Apple added Spaces as part of OS X 10.5 "Leopard", and hacker types have been criticizing it ever since.
But I'm already too old to care about customizing the heck out of my desktop. I'd rather have something that works by default, and Spaces largely works.

Spaces lets you to define N virtual desktops, and to switch to each desktop via "<modifier>-N", where N=[1-9] and <modifier> is one of (ctrl,command,option). This is a pretty good way to do things by default; it's flexible, and doesn't conflict with other apps.

I've also had intermittent RSI problems for years. Unfortunately for me, pressing any key-combination hundreds of times a day is bad for my hands. I'd rather make it a single keystroke, so my hands don't have to perform gymnastics on such a regular basis.

I haven't found a clean answer yet. But I do have a dirty hack that works.

1. Download Proxi from Griffin Technology.

It's a free app which helps you customize how your Mac responds to input devices -- keyboard, mouse and other controllers like Griffin's Powermate and AirClick. (Don't have 'em, but I think they are nifty :)

2. Start Proxi and define some Triggers

I use 4 "spaces", so I define four triggers in Proxi. One for each space, mapping:

I chose F1-F4 because, well, I don't use them for anything else. I know F1 sometimes means "Help" and F4 sometimes means "Close Window". Those date from the old, PS/2-era IBM CUA guidelines. But in practice, I never use these keys on a Mac.

Open System Preferences -> Spaces. Unselect the "switch directly to a space" modifier key, but remember which one it was -- we'll use it below. (I use "option")

Switch to Proxi and define some triggers, one for each space.

  1. Gear on bottom left: "Insert trigger -> Hotkey Monitor"
  2. "Set" the hotkey. Click "Set" button, tap the F-key (F1 for Space 1)
  3. Gear, bottom middle: "Insert task -> Key Press"
  4. "Set" it to your old direct-switch keystroke combo. (Option-1 for Space 1)

Repeat for each space. When you're done,

Go back to System Preferences -> Spaces. Re-enable the "switch directly to space" modifier key, setting it to "Option" or whatever modifier you used above.

Now try pressing F1, then F2. You should see your Mac switching from Space 1 to Space 2!

3. Leave Proxi running

You'll probably want to go back to Proxi's Preferences and select "Start at Login". The triggers only work while Proxi is running, so don't close it.

Yeah, it's a hack...

Like I said earlier, this solution is somewhat hackish. A better solution would replace the "Key Press" task with a direct "Change Space" task, perhaps implemented via Applescript.

Does anyone know how to improve this recipe? If so, please let me know!