Skip to content

Instantly share code, notes, and snippets.

@drmohundro
Last active September 21, 2017 00:36
Show Gist options
  • Save drmohundro/0c9236430e4d201b5aff to your computer and use it in GitHub Desktop.
Save drmohundro/0c9236430e4d201b5aff to your computer and use it in GitHub Desktop.
Karabiner private.xml to swap option and command keys for Parallels
<?xml version="1.0"?>
<root>
<appdef>
<appname>PARALLELS</appname>
<equal>com.parallels.desktop.console</equal>
</appdef>
<devicevendordef>
<vendorname>MICROSOFT</vendorname>
<vendorid>0x045e</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>MICROSOFT_ERGONOMIC_KEYBOARD</productname>
<productid>0x00db</productid>
</deviceproductdef>
<item>
<name>Swap Command and Option (Parallels)</name>
<identifier>private.app_parallels_swap_command_and_option</identifier>
<only>PARALLELS</only>
<device_only>DeviceVendor::MICROSOFT, DeviceProduct::MICROSOFT_ERGONOMIC_KEYBOARD</device_only>
<autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen>
<autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>
<autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_L</autogen>
</item>
</root>
@drmohundro
Copy link
Author

Other Updates for Karabiner:

  • Enable "Application Key to Option_R (right option key)"

@drmohundro
Copy link
Author

Change Log

  • Nov. 17, 2014
    • Updated to support both left and right alt keys.
  • Nov. 18, 2014
    • Updated to only do this for both Parallels and when using my Microsoft Natural Ergonomic Keyboard. I want the internal MacBook Pro keyboard to still behave the same way.
    • Note that you'll want to use Karabiner's EventViewer to determine your device's specific vendor id and product id (see docs for more details).

@NicolasVanhecke
Copy link

NicolasVanhecke commented Dec 16, 2016

@drmohundro

You seem to understand this quiet a bit. Would you be able to help me with the problem I am having?
I want to remap the WINDOWS key to the ALT_LEFT key (if possible ONLY for my windows keyboard, if not profiles are fine).
Thing is that the command and alt key on mac are reversed on a windows keyboard. I would like to start coding with my mechanical keyboard (which is the windows layout). This is with removable keycaps, so when I would start working I would simple switch the two keycaps.

BTW: this is what I have now, but it is not working.. (also dont know how to check if this is 'active').

<item> <name>Swap Command and lEFT Alt</name> <identifier>private.swap_command_and_alt</identifier> <autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> <autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen> </item>

Thanks

@drmohundro
Copy link
Author

@NicolasVanhecke my apologies, but I never was notified of your comment, otherwise I would have tried to respond!

I'm not sure off hand what might be going on with your problem, but I will say that, if you're on MacOS Sierra, Karabiner doesn't work any more and you'd need Karabiner Elements instead. That's actually what I'm using now and it has a GUI for mapping keys per device (which is a relatively new feature). It's a lot easier than messing with the private.xml file.

@drmohundro
Copy link
Author

Regarding notifications... oh. This is why - isaacs/github#21. 🤦‍♂️

@drmohundro
Copy link
Author

See latest Karabiner Elements support to give me all of these options at https://github.com/drmohundro/dotfiles/blob/master/config/karabiner/karabiner.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment