Sunday, July 27, 2014

Karabiner: a keymapping tool for osx

I have found a wonder tool for remapping keys on osx: Karabiner - Software for OS X

User manual: Karabiner - Software for OS X

User's keymap settings are stored in a file called private.xml, it can opened like this:

Note that there is also a "Event Viewer" in which you can look up keycodes and app identifiers in action.

After browsing through the documentation I have come up with a xml configuration specifically effective for Eclipse text editor area:

<?xml version="1.0"?>
<root>
  <appdef>
    <appname>ECLIPSE</appname>
    <equal>org.eclipse.platform.ide</equal>
  </appdef>
  <item>
    <name>Esc to ctrl-bracket three times in Eclipse</name>
    <identifier>private.esc.to.c.bracket.three.times.eclipse</identifier>
    <only>ECLIPSE</only>
    <uielementrole_not>AXTextArea</uielementrole_not>
    <autogen>
      __KeyToKey__
      KeyCode::ESCAPE,
      KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L, KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L, KeyCode::BRACKET_LEFT, ModifierFlag::CONTROL_L 
    </autogen>
  </item>
</root>

Since I use vim mode (vrapper plugin), I use the Esc key a lot, so I mapped Esc to its equivalent ctrl-[ repeated three times.

This is indeed a extraordinary piece of software, I will definitely learn more about it later!

0 comments: