How can I rebind keyboard keys in OS X? I need a custom keyboard shortcut for back slash \.

I have created ~/Library/KeyBindings/DefaultKeyBinding.dict and put this in it:

{
    "@ö" = ("insertText:", "\\");
}


It is supposed to trigger back slash when pressing ⌘ + ö 
(Yes, I have an "ö" character on my keyboard).

When trying to source the file, I get this error:

-bash: DefaultKeyBinding.dict: line 2: syntax error near unexpected token `('
-bash: DefaultKeyBinding.dict: line 2: `    "@ö" = ("insertText:", "\\");'


What's wrong with the syntax? Is there a better way?
To enable CmdÖ -> \ just remap the key combo with Karabiner. The shortcut you need isn't pre-defined so you have to write your own:


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

Example 1 (cmdÖ -> \):

&lt;?xml version="1.0"?&gt;
&lt;root&gt;
    &lt;item&gt;
      &lt;name&gt;Command-Ö to Backslash&lt;/name&gt;
      &lt;appendix&gt;(Change Command-Ö to \)&lt;/appendix&gt;
      &lt;identifier&gt;remap.command_ö_to_backslash&lt;/identifier&gt;
      &lt;autogen&gt;__KeyToKey__ KeyCode::GERMAN_O_UMLAUT, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_COMMAND, KeyCode::KEY_7, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L&lt;/autogen&gt;
    &lt;/item&gt;
&lt;/root&gt;


Example 2 (cmd_RÖ -> \ cmd_R is the right command key only, cmd_LÖ doesn't have an output!):

&lt;?xml version="1.0"?&gt;
&lt;root&gt;
    &lt;item&gt;
      &lt;name&gt;Command_R-Ö to Backslash&lt;/name&gt;
      &lt;appendix&gt;(Change Command_R-Ö to \)&lt;/appendix&gt;
      &lt;identifier&gt;remap.command_r_ö_to_backslash&lt;/identifier&gt;
      &lt;autogen&gt;__KeyToKey__ KeyCode::GERMAN_O_UMLAUT, ModifierFlag::COMMAND_R, KeyCode::KEY_7, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L&lt;/autogen&gt;
    &lt;/item&gt;
&lt;/root&gt;


Example 3 (cmd_R -> \ you can't use the right command key for any other purpose then):

&lt;?xml version="1.0"?&gt;
&lt;root&gt;
    &lt;item&gt;
      &lt;name&gt;Command_R to Backslash&lt;/name&gt;
      &lt;appendix&gt;(Change Command_R to \)&lt;/appendix&gt;
      &lt;identifier&gt;remap.command_r_to_backslash&lt;/identifier&gt;
      &lt;autogen&gt;__KeyToKey__ KeyCode::COMMAND_R, KeyCode::KEY_7, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L&lt;/autogen&gt;
    &lt;/item&gt;
&lt;/root&gt;


Example 4 (cmd_R -> \ similar to example 3 but you can use the right command key as normal command key-> hitting cmd_R yields \ but cmd_RS saves files):

&lt;?xml version="1.0"?&gt;
&lt;root&gt;
    &lt;item&gt;
      &lt;name&gt;When you type Command_R only, send Backslash&lt;/name&gt;
      &lt;appendix&gt;(Change Command_R lazy to \)&lt;/appendix&gt;
      &lt;identifier&gt;remap.command_r_lazy_to_backslash&lt;/identifier&gt;
      &lt;autogen&gt;__KeyOverlaidModifier__ KeyCode::COMMAND_R, KeyCode::VK_LAZY_COMMAND_R, KeyCode::KEY_7, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L&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.