How to bind ⌘← and ⌘→ to previous and next tab in Safari 10

keyboardsafari

I'm used to having Command-Left Arrow (+) and Command-Right Arrow (+) to switch between tabs, going to the previous and next tabs. I have configured these keys in System Preferences → Keyboard → Shortcuts for Safari.app.

However, configuring these shortcuts only works sometimes in Safari 10.1 under macOS 10.12. The behavior is this:

  • When pressed in a tab with an active text box, the caret moves to the beginning and end of the row instead
  • When pressed in a tab with history forwards or back, Safari goes forward or back in history instead
  • Only when pressed on a tab that doesn't have the two above conditions, Safari switches to the previous or next tab

How can I disable the two other behaviors or configure the keys correctly so that I can use + and + as previous and next tab shortcuts?

Best Answer

You can use Keyboard Maestro to overwrite that ambiguous behavior in Safari and map ⌘←/⌘→ to switch between tabs regardless of any context (text field, history availability), to make it work just like it does in Chrome. It's a pretty straightforward macro like "When ⌘← hotkey is pressed, execute “Previous Safari Tab” action" in a macro folder limited to Safari. However, Keyboard Maestro is not free.

Maybe you could also create a free Applescript service to run Window⟶Show Next Tab command (since this command ignores context, unlike the respective keyboard shortcut) and change system shortcut ⌘←/⌘→ to run that service instead (would like need to add Safari to Accessibility to allow a script manipulating menu items).