Netflix interferes with Safari custom tab change shortcut

safarishortcutvideo

I used this method to set the tab-changing shortcut in Safari to Cmd+Opt+Left/Right (same as in Chrome). It works, except that when I'm watching Netflix and try changing tabs while the video is playing, it registers only as left/right and makes the video jump backward/forward by 10 seconds, instead of changing tabs as intended.

Is there a way to fix this? I would like Cmd+Opt+Left/Right to always change tabs, even if the webpage I'm on has specific behavior for the left/right keys on their own.

Strangely, Youtube does not have this issue, even though the left/right keys have similar behavior for the Youtube video player.

Best Answer

Using hammerspoon. After installing hammerspoon (I used brew cask install hammerspoon), just edit/create the file ~/.hammerspoon/init.lua to include:

left = hs.hotkey.new({"cmd", "alt"}, "left", function()
  hs.eventtap.keyStroke({"cmd", "shift"}, "[")
end)

right = hs.hotkey.new({"cmd", "alt"}, "right", function()
  hs.eventtap.keyStroke({"cmd", "shift"}, "]")
end)

hs.application.watcher.new(function(appName, eventType, appObject)
  if appName == "Safari" then
    if eventType == hs.application.watcher.activated then
      left:enable()
      right:enable()
    elseif eventType == hs.application.watcher.deactivated then
      left:disable()
      right:disable()
    end
  end
end):start()

Then start Hammerspoon.app.

Then enable Hammerspoon control in System Preferences > Security & Privacy > Privacy > Accessibility. (Maybe you will need to Reload Config from Hammerspoon's menu bar item after this).