Search code examples
macosterminalkarabiner

Karabiner how to map two KeyCodes to another two KeyCodes


Karabiner has been very awesome with its remapping for its emulating of vim mode. My favorite part is being able to press s + hjkl and use that as a replacement for cursor keys. I'm trying to add another shortcut that would function similarly, let's say 's+g' and I want to map this to 'esc+b' so when I'm in the terminal I can hit 's+g' and it will jump backwards a word. gone to the vim xml file on github to try to understand:

https://github.com/tekezo/Karabiner/blob/master/src/core/server/Resources/include/checkbox/vi_mode.xml

but it's only confusing me more. It seems like you have to set up aliases of some sort if you want to do what I'm trying to achieve? The sample remaps only show how to do modifier keys to regular keys but how do I bind two regular keys?


Solution

  • In order to bind two simultaneous keystrokes where one is not a modifier, you need to use __SimultaneousKeyPresses__ instead of __KeyToKey__.

    Here's example of what you want to do:

      <item>
          <identifier>private.sgescb</identifier>
          <name>s+g to esc+b</name>
          <autogen>
              __SimultaneousKeyPresses__
              KeyCode::S, KeyCode::G,
              KeyCode::ESCAPE, KeyCode::B
          </autogen>
      </item>