Select input language by Caps Lock in Mac OS X

(This article is as well available in Russian).

I found a new way to bind input language (input source) switch to the Caps Lock button in Mac OS X. Unlike Kirgudu, the Russian application which is also able to do that, my method works without a lag, so language changes instantly after pressing the Caps Lock button. This is especially important if you’re a fast typer: with Kirgudu, when you start typing right after pressing the Caps Lock, the first letters of a new word might appear in a previously selected language. (I.e. if you used English and Russian layouts, instead of www.google.com, you’d type ццw.google.com).

The logic behind my method is: in OS X system settings, I bind input source selection to the F19 button (instead of default Cmd + Space — which you will still be able to use, by the way). Then, by the means of PCKeyboardHack (driver patch with a “System Preferences” pane, written by Takayama Fumihiko) Caps Lock is remapped to F19. And of course, it will work regardless of your keyboard having a F19 key.

It should work on Mac OS X Leopard and Snow Leopard — but I don’t know about Tiger.

Cons

  1. You will not be able to toggle the Caps Lock mode anymore.
  2. The green light on the button of your keyboard will not change as you change the input source — it will be lid constantly.
  3. You will have to uninstall DoubleCommand and any other keyboard remappers.
  4. This way is harder than simply installing Kirgudu.

If you don’t like it later or something won’t work, you will always be able to revert changes. Every mentioned program has an uninstaller.

Step-by-step guide

  1. Download and install PCKeyboardHack (requires a reboot).
  2. In System Preferences go to “Keyboard” → click the “Modifier Keys…” button and for Caps Lock choose “No action”.Caps Lock No Action
  3. If your keyboard does have a F19 key, you may skip this step. Otherwise download my application (actually, this is just a line of AppleScript wrapped into an application), which will press this button virtually. After downloading, unpack and mount the .dmg and drag “Simulate F19” to the Dock (temporarily).Simulate F19 To Dock
  4. Switch to “Keyboard Shortcuts” tab in the same window, select “Keyboard & Text Input” and find “Select the previous input source” (or “next source” — does not matter). Double click the shortcut to change it. Now, if you have F19 on your keyboard, just press it, otherwise press Simulate F19.app in the Dock (if your window lost focus, try once or twice again until the result: double click the shortcut field and press Simulate F19.app). Here is what you should get eventually:Bind Change Layout To F19If it worked out, you can remove Simulate F19 from the Dock.
  5. Return to the main window of System Preferences and choose PCKeyboardHack. Tick “Change Caps Lock” and in the “keycode” column change 51 to 80.Change Caps Lock Keycode

Done!

Additional information

If there is a noticeable delay, download and install KeyRemap4MacBook (requires a reboot). Choose it in System Preferences, select “Mapping” tab, in search field type “capslock” and tick “Enable CapsLock LED Hack” thereafter. This is required to suppress accidental activation protection, used for the Caps Lock button in Mac OS X.Tick Caps Lock Led Hack

For advanced users: instead of F19 you may use any other key in the range of F13–F19. To do that, in the third step choose an appropriate application (Simulate F13, Simulate F14 etc). And in the fifth step, instead of 80, you need to pick a keycode according to the following table:

Button Keycode
F13 105
F14 107
F15 113
F16 106
F17 64
F18 79
F19 80
This entry was posted in How to’s and tagged , , , , , . Bookmark the permalink.

4 Responses to Select input language by Caps Lock in Mac OS X

  1. Thank you for useful information.

    Changing language by the one-shot push of the Command key is also convenient, try it if interested.
    http://pqrs.org/macosx/keyremap4macbook/files/KeyRemap4MacBook-6.5.55.pkg.zip

    For Russian > Change Command_L Key > Command_L to Command_L (+ When you type Command_L only, change inputmode to english)
    For Russian > Change Command_R Key > Command_R to Command_R (+ When you type Command_R only, change inputmode to russian)

  2. Niklas Rosen says:

    Great guide, thanks!

  3. Emily says:

    Thanks so much! This is a fantastic tool for my new Mac!

  4. Hey thanks to you for the last new entry.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>