23

I've noticed more and more websites are stealing browser hotkeys.

Alt+D is perhaps the most obnoxious. I use this constantly to change website. Yet so many websites are stealing the hotkey for their own system - which is really stupid because if you are going to put the effort in to learn hotkeys for a website, you've probably already put the effort in to learn hotkeys for the browser! For example, Google Sheets stealing Alt+D to open the data menu.

Is there any way to prevent websites from overriding browser shortcuts?

Art Gertner
  • 7,429

2 Answers2

9

Not exactly a way to prevent but a workaround (that also works in Google Sheets).

In short, we want the browser to focus something else besides the website so we can use any shortcut we want. And there are some shortcuts that get you out of the website's grip and focus to the browser's other elements:

  • Alt: Focus browser menu. This is the easiest one but there are other options if the website blocks this.
  • Alt+D: Focus address bar
  • Ctrl+L: Focus address bar
  • F6: Focus address bar
  • Ctrl+E: Focus search bar (or address bar and start searching)
  • Ctrl+K: Focus search bar (or address bar and start searching)
  • Ctrl[+Shift]+Tab: Change tab as the last resort

So even if the website is blocking some shortcuts, one of these will most likely work. When you get focus something else besides the website you can use the shortcut you wanted to use in the first place.

E.g. to focus address bar while in a Google Sheets document press Alt (and lift your finger), then press Alt+D.

Taylan
  • 722
0

You can use JavaScript and an extension like Violentmonkey to prevent a website stealing particular keyboard shortcuts.

For an example of a script that targets overwriting Alt+Left and Alt+Right (browser history navigation), see https://github.com/crittermike/shortkeys/issues/625#issuecomment-2143389622

  1. Copy the script to the clipboard.
  2. Right-click the Violentmonkey extension icon.
  3. Choose Options.
  4. Click the Plus button for a New script.
  5. Paste in the script.
  6. Click Save & close.
  7. Reload the website you want to test this on.
RyanCu
  • 131
  • 2