Saturday, June 7, 2014

How to remap Command-Tab to Alt-Tab on OSX..

I've been trying to find on Stack Overflow how to remap this key on OSX, and it appears you can accomplish this goal by using the powerful KeyRemap4MacBook program.

You'll want to download the install .dmg program and then use the software to upgrade to the latest version (for some reason, the beta version is not available on the main web site as a link).

The challenge?  How do you only enable this functionality on external keyboards, such as the Kinesis Essential keyboard?   Here's the XML that I generated that worked, relying on the docs.

<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>KINESIS</vendorname>
<vendorid>0x0518</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>ADVANTAGE</productname>
<productid>0x0001</productid>
</deviceproductdef>
<item>
<name>Kinesis remapping</name>
<identifier>Option_Tab_Remapping</identifier>
<device_only>DeviceVendor::KINESIS, DeviceProduct::ADVANTAGE</device_only>
<autogen>__KeyToKey__ KeyCode::TAB, ModifierFlag::OPTION_L, KeyCode::TAB, ModifierFlag::COMMAND_L</autogen>
</item>
</root>
view raw kinesis-remap hosted with ❤ by GitHub
Once this configuration is setup, you need to click on the reload XML and go to Key remap and enable the configuration (search for "Kinesis").

You'll also want to grant the AXNotifier program the ability to monitor changes in your window, which allow you to be more granular about what programs you want to target.  For instance, if you want to remap keys for page up and page down in Emacs, you can use the following Gist:

<?xml version="1.0"?>
<root>
<symbol_map type="KeyCode" name="PAGE_UP" value="0x74" />
<symbol_map type="KeyCode" name="PAGE_DOWN" value="0x79" />
<windownamedef>
<name>emacs_terminal</name>
<regex>emacs</regex>
</windownamedef>
<devicevendordef>
<vendorname>KINESIS</vendorname>
<vendorid>0x0518</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>ADVANTAGE</productname>
<productid>0x0001</productid>
</deviceproductdef>
<item>
<name>Kinesis remapping</name>
<identifier>Option_Tab_Remapping</identifier>
<device_only>DeviceVendor::KINESIS, DeviceProduct::ADVANTAGE</device_only>
<autogen>__KeyToKey__ KeyCode::TAB, ModifierFlag::OPTION_L, KeyCode::TAB, ModifierFlag::COMMAND_L</autogen>
</item>
<item>
<name>Emacs pageup/pagedown</name>
<identifier>emacs_pageup_pagedown</identifier>
<windowname_only>emacs_terminal</windowname_only>
<device_only>DeviceVendor::KINESIS, DeviceProduct::ADVANTAGE</device_only>
<autogen>__KeyToKey__ KeyCode::PAGE_UP, KeyCode::V, ModifierFlag::OPTION_L</autogen>
<autogen>__KeyToKey__ KeyCode::PAGE_DOWN, KeyCode::V, ModifierFlag::CONTROL_L</autogen>
</item>
</root>
view raw emacs_keyremap hosted with ❤ by GitHub

No comments:

Post a Comment