How to bind a key to press two separate keys

In other words, if I press "x", it registers as me pressing "a" and "b" sequentially.

I run Mac OSX Yosemite 10.10.5. A Karabiner solution eludes me, thus I am researching more.


Solution 1:

To make this work you have to use a third party tool: Karabiner.

  1. Download, install and open Karabiner
  2. Open in the menulet Karabiner -> Preferences
  3. Open the tab Misc & Uninstall
  4. Hit the button Open private.xml
  5. Open the file private.xml with an appropriate editor
  6. Enter the customized keycode

    <?xml version="1.0"?>
    <root>
        <item>
            <name>X to A and B</name>
            <appendix>When you type X, A and B are written</appendix>
            <identifier>x2ab</identifier>
            <autogen>__KeyToKey__ KeyCode::X, KeyCode::A, KeyCode::B</autogen>
        </item>
    </root>
    
  7. Save the file

  8. Open in the menulet Karabiner -> Preferences the tab Change Key
  9. Hit the ReloadXML button
  10. Enable the remapping. It should be listed at the beginning.

You can restrict the keybinding to particular apps if needed by adding additional tags. Leave a comment if you want to know how or specify your question.