mdn / yari

The platform code behind MDN Web Docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MDN intercepts Firefox's native `/` shortcut

eevee opened this issue · comments

Firefox uses / to mean "quick find in page". MDN intercepts that to mean the completely different "search the whole website". This is a very weird thing to do and sets a somewhat unpleasant precedent for the rest of the web, given that Mozilla's name is on both products.

This was the original search shortcut. Ctrl-K was added as a secondary shortcut in #5962, and it was made not to trigger on Ctrl-Shift-K in #7067.

Note, the same shortcuts apply on GitHub (with two different purposes - Ctrl-K opens a "command-palette" inside a details-dialog element, while s or / focuses the typical search bar)

I assume this needs to be discussed. Slash, as a keyboard shortcut for search was added to yari in #93 by former MDN employee peterbe. It may have been copied from the pre-yari days.

Also note, on any Google search page (e.g. https://www.google.com/search?q=test), slash focuses the search field, so this isn't entirely uncommon.

I did once manage to get GitHub to remove its / shortcut, but it snuck back in later. I suppose I'm not surprised that Google and Microsoft engineers don't bother checking if they're overriding Firefox shortcuts. :)

It's also worth noting, Ctrl-K itself is overriding a Firefox shortcut too. On websites where Ctrl-K does not have any other function, it searches your default search engine via the address bar.

It's a question of what the best keyboard shortcut for search might be and whether avoiding overriding shortcuts is so paramount that conventions followed by other websites should be ignored by MDN. I suppose the difference is Ctrl-K is pretty unpopular as a browser shortcut.

On websites that override Ctrl-K, you can accomplish the same thing with Ctrl-L followed by Ctrl-K, but that's increasing the number of shortcuts to two instead of one.

I use Ctrl-K all the time and I've run afoul of that on MDN too, but at least I can press it a second time to get where I actually wanted to go.

Honestly, I don't understand the need to override useful native browser shortcuts for a single website at all. I, necessarily, use Firefox itself far more often than I use MDN (or any other singular site), so I'm much more invested in Firefox shortcuts than MDN shortcuts, and having / and Ctrl-K sometimes stop working is incredibly irritating. It's arguably worse with Ctrl-K, since that has nothing to do with the site that's open, so I don't develop very strong associations for when it will break. It just becomes a fun surprise.

GitHub's s seems fine. Or even the native accesskey, but I guess that's passé.