MacOS – Re-map keys on keyboard

keyboardmacos

I know how to re-map my modifier keys, so my caps lock can act as a ctrl key, for example.

I'm wondering if there's a way to re-map they dash/underscore key (next to +/=). Instead of it producing a dash or hyphen, I'd like it to produce an em dash. And pressing shift+opt+dash (the current shortcut for an em dash) key would produce a normal dash.

Based on Karl's answer, I tried using BetterTouchTool (as Global shortcuts and also TextEdit specifically), but remapped keypresses just seem to be ignored.

enter image description here

Best Answer

Install and launch Karabiner. In the menubar open the menulet Karabiner -> Preferences. Then hit the tab "Misc & Uninstall" and "Open private.xml"

Paste the following lines into the opened xml file:

<?xml version="1.0"?>
<root>
    <item>
      <name>Swap Minus and Alt+Shift+Minus</name>
      <identifier>remap.minus_and_optionlshiftlminus</identifier>
      <autogen>
        __KeyToKey__ 
        KeyCode::MINUS, ModifierFlag::NONE,
        KeyCode::MINUS, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L
      </autogen>
      <autogen>
        __KeyToKey__
        KeyCode::MINUS, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L,
        KeyCode::MINUS,
      </autogen>
    </item>
</root>

and save the file.

Return to the tab "Change Key", hit "ReloadXML" and enable "Swap Minus and Alt+Shift+Minus". It should be the first entry listed.

If you are left-handed you may replace _L by _R in the xml file.