I like Mac OS X very much. But I also have to use MS Windows for some tasks that Mac OS X cannot do, such as full-featured MS Office, MS Project, MS Visio, MindJet/MindManager, stock trading terminals, most games, etc.
And I also like to switch my keyboard layouts with CapsLock instead of default Cmd+Space or Alt+Shift. You would never believe how convenient it is until you try it for yourself.
But when I use both Parallels Desktop with MS Windows as a guest OS and PCKeyboardHack for CapsLock keyboard layout switching, I find myself limited to only one of these scenarios:
- Use CapsLock to switch keyboard layouts in Windows as in Mac OS X, but Cmd+Tab goes to Windows and switches between Windows applications instead of Mac OS X applications.
- Use Cmd+Tab to switch between Mac OS X applications, but Windows keyboard layouts should be switched with native Alt+Shift or Ctrl+Shift, not with CapsLock as in Mac OS X.
Actually, this limitation affects all Mac OS X system shortcuts, not only Cmd+Tab. For example, Cmd+Shift+4 does not work for screenshots, Cmd+Ctrl+N does not work for Evernote, etc.
The perfect scenario — Cmd+Tab for Mac OS X applications and CapsLock for keyboard layouts both in Mac OS X and Windows — is impossible with these tools. Here is a solution how to implement this perfect scenario.
First of all, you need KeyRemap4MacBook installed. If you are experienced Mac OS X user, most likely you already have it. If you are not, get it right now — it is good for many keyboard-related tricks (like this).
Launch it, then go to “Misc & Uninstall” tab, and click “Open private.xml”. In the Finder window, open private.xml file for editing. Add these lines between elements, so the file looks like this (gist):
<?xml version="1.0"?> <root> <item> <name>Change F19 to switch language in VMware, Parallels, VirtualBox</name> <item> <name style="important">First, remap CapsLock to F19 (code 80) in PCKeyboardHack.</name> </item> <item> <name>F19 (CapsLock) to Alt+Shift</name> <identifier>private.f19caps_to_altshift_in_vm</identifier> <only>VIRTUALMACHINE</only> <autogen>__KeyToKey__ KeyCode::F19, ModifierFlag::NONE, KeyCode::SHIFT_L, ModifierFlag::OPTION_L</autogen> </item> <item> <name>F19 (CapsLock) to Ctrl+Shift</name> <identifier>private.f19caps_to_ctrlshift_in_vm</identifier> <only>VIRTUALMACHINE</only> <autogen>__KeyToKey__ KeyCode::F19, ModifierFlag::NONE, KeyCode::SHIFT_L, ModifierFlag::CONTROL_L</autogen> </item> </item> </root>
Now, save it and go to “Change Key” tab of KeyRemap4MacBook, and click “Reload XML” button. You will see two new modes at the top of the list.
Enable one of the modes that corresponds to your Windows settings (Alt+Shift or Ctrl+Shift).
Then go to Parallels Desktop preferences (NB: do not confuse it with virtual machine’s configuration), “Shortcuts” tab, “System Shortcuts” section, and set “Send system shortcuts” to “On condition”. This mode will send Cmd+Tab to host Mac OS X, not guest MS Windows.
At last, go to your MS Windows virtual machine, and check that keyboard layouts switching works with CapsLock as it does in host Mac OS X, and that Cmd+Tab switches between host Mac OS X applications, and Alt+Tab switches between MS Windows applications.
You are welcome!