Remap SHIFT + SPACE to underscore? I'd like to remap the shift key (⇧) + space (␣) to underscore (_)

I'd prefer to not have to install any third party tools if possible.

Similar question for windows
If you don't want to use a third party tool, you will face a similar problem as the OP in this question (DefaultKeyBinding.dict: Syntax error near unexpected token) that only applications which use the Cocoa text system will support this. 

Additionally it appears that the shift ⇧ key can't be properly used as modifier key if shift ⇧+some key doesn't have another representation than an unmodified some key - and shift ⇧+space doesn't have one.

You may either create a DefaultKeyBinding.dict or install Karabiner and configure a custom keycode.

DefaultKeyBinding.dict (only applications which use the Cocoa text system will support this)

Open Terminal and enter:

mkdir ~/Library/KeyBindings
touch ~/Library/KeyBindings/DefaultKeyBinding.dict 


Use nano ~/Library/KeyBindings/DefaultKeyBinding.dict to add (using another shortcut like cmd ⌘ctrl ^space here):

{
    "@^ " = ("insertText:", "_");
}


to output an underscore.

Karabiner (all apps should support this)


Download, install and open Karabiner
Open in the menulet Karabiner -> Preferences
Open the tab Misc &amp; Uninstall
Hit the button Open private.xml
Open the file private.xml with an appropriate editor
Enter the customized keycode

&lt;?xml version="1.0"?&gt;
&lt;root&gt;
    &lt;item&gt;
        &lt;name&gt;Shift Space to Underscore&lt;/name&gt;
        &lt;appendix&gt;(Change Shift-space to _)&lt;/appendix&gt;
        &lt;identifier&gt;remap.shiftspace2underscore&lt;/identifier&gt;
        &lt;autogen&gt;__KeyToKey__ KeyCode::SPACE, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_SHIFT, KeyCode::MINUS, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_SHIFT,&lt;/autogen&gt;
    &lt;/item&gt;
&lt;/root&gt;

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