MacOS – Safari: swap alt modifier with cmd

keyboardmacossafari

I use Firefox and Chrome as my main navigators, but I use sometimes Safari to test some developments.

On Firefox and Chrome, typing an URL in the address bar and then pressing Alt + Return makes a new tab to be opened.

On Safari, typing an URL in the address bar and then pressing Alt + Return makes the target address saved to a file (which annoys me because it makes an unuseful file in my Download folder).

To open a new tab after typing the address, I have to use the Cmd + Return.

I wonder if it is possible to swap cmd and alt key only for Safari (not other apps) and how to do this, or at least make Safari open a new tab when I press Alt+Return in the address bar.

One last thing: I am on Mavericks

Any idea ?

Best Answer

You can use Karabiner with a private.xml such as this:

<?xml version="1.0"?>
<root>
  <appdef>
    <appname>SAFARI</appname>
    <equal>com.apple.Safari</equal>
  </appdef>
  <item>
    <name>Swap ⌥↩︎ and ⌘↩︎</name>
    <identifier>SwapAltEnterAndCmdEnter</identifier>
    <only>SAFARI</only>
    <autogen>
      __KeyToKey__
      KeyCode::RETURN, VK_COMMAND | ModifierFlag::NONE,
      KeyCode::RETURN, ModifierFlag::OPTION_L
    </autogen>
    <autogen>
      __KeyToKey__
      KeyCode::RETURN, VK_OPTION | ModifierFlag::NONE,
      KeyCode::RETURN, ModifierFlag::COMMAND_L
    </autogen>
  </item>
</root>

You can find the manual here to know how to edit the private.xml file and update your configuration.

You have to check the small checkbox of the newly defined rule to make it work.