18

When building a rich web app, can it be acceptable to take over the CTRL + F shortcut to focus your app's search box, instead of the browser's searchbox? For example, an app's own search box can do a server side search, finding content that is not rendered on the screen.

If yes, when? If no, what are the downsides?

My use case is a frequently used business app with infinite scrollable content.

13
  • 44
    For what it's worth, I sometimes encounter web pages that do this, and it always frustrates me. I've never encountered a situation where overriding that behaviour actually helped me.
    – marcelm
    Commented Sep 3 at 8:04
  • 2
    I can appreciate this in the case of web based PDF editors for example. In that case native CTRL + F is kind of useless because it only searches currently rendered pages while a custom search function can search the whole document, on server side even if necessary. Commented Sep 3 at 8:50
  • 17
    To me, CTRL+F is a safe shortcut that lets me easily search the page, free from any of the page owners wants or desires. If I found that it has been intercepted/altered in some way, I might actually stop using the website/app entirely. I feel the same way about copy/paste and the context menu, which are more often intercepted. Commented Sep 3 at 13:48
  • 2
    Broadly speaking, I'm not a fan of taking over any Ctrl key shortcut, because you don't necessarily know what the user's browser might use it for. Commented Sep 3 at 21:22
  • 2
    @supercat If the default CTRL+F functionality wouldn't be usable for any reason, I would still want it to be left as is. That would show me that there is close to no text to search on the page, which is also information. I'd recommend making the labels actual text on the page instead of intercepting the search function. Commented Sep 4 at 6:25

12 Answers 12

20

CTRL+F has an important feature by default in that it does not change page content: No elements of the page appear, disappear, or change content when typing and submitting find queries.

Focusing a general-purpose search field that does a search request is not helpful since it will break that expectation, by causing network requests and the contents of the page to change.

For "search in website", use any other key combination available, for example GitHub uses "S".


In my opinion, the only reason to overwrite built-in browser behaviour is if your website's implementation broke it in the first place, for example by using opaque rendering methods like Canvas (example: Google Docs) or virtualized scrolling (example: GitHub file view), where if no replacement was provided, the functionality would simply not work in any meaningful manner.

3
  • The assertion that default find in page has no effect on page contents is false. If matching text content is found in a collapsed <details>, it will be expanded, and if found in an element with hidden=until-found, the element will be made visible. Commented Sep 3 at 21:55
  • Sure, hidden=until-found is A) experimental and B) opt-in by the page, which should be used to reinforce user expectations. Details is semantically in the page, and unless you go out of your way to implement a website poorly such that opening a details destroys other page content, the point stands.
    – Kroltan
    Commented Sep 5 at 15:40
  • Thank you and everyone for your insightful answers. It was hard picking an accepted answer but settled for yours since it seem to best adress the specific CTRL + F case. Insights about shortcuts in general are of course very helpful as well. Commented Sep 6 at 15:42
31

I would always tell people in my team (and remind myself) to be very very careful overriding any default browser behavior and only go for it if you are certain its an improvement. Through testing and verifying with development.

Reasoning is:

  • Expectations: Ctrl+F is so engrained in any piece of software that users will have clear expectations what that shortcut does. Assuming that those that use it do this on purpose. Connecting it to your search box breaks this natural flow leading to all sorts of issues. For example: if users of your webapp only use it ever so often, they may never "learn" that ctrl+f does something different, and get annoyed everytime they are confronted with it.
  • Expectations #2: another scenario is that users simply want to do what Ctrl+F does, find a piece of text on the current page. Can you be certain that your change will make this at least just as easy? Or will you make it more difficult? If the latter is the case, you may frustrate users.
  • Break other tools As Paul Boag explains in this post. Even the smallest of changes can have considerable consequences later down the line. Other tools may rely heavily on the default behavior of Ctrl+F which might break due to your change. Not saying it applies here, but its something to consider.
  • Maintenance: In my experience, disabling native/default behavior is notorious for maintenance issues. Regular browser updates and differences in browsers easily break the custom behavior. Again, not saying it applies here, but do take it up with your developers whether this may be the case.

We actually did something similar in our platforms where we use "/" as shortcut to call the searchbox while keeping CTRL+F in place. So far it works for us and we are not noticing any breaking issues.

My advice would be: don't replace CTRL+F but find an implementation that complements the default behavior whilst keeping standards intact. Avoid the rabbit hole


Update

As mentioned in the comments, [ / ] is used more often as an alternative to triggering search. Firefox uses it for quicksearch, but more websites like Github, Jira and Figma use it to trigger their search.

7
  • 9
    Related: GitLab has certain cases where it overrides Ctrl+F, but only inside a scrollable area of text - if another element was last clicked, you get the default behavior. It’s a decent balance, IMO Commented Sep 2 at 21:13
  • 2
    The "/" does unfortunately not work with keyboard layouts that does not have it without modifier key, e.g. Nordic. Microsoft Teams (on the web) uses CTRL + ALT + E to search globally, but overrides CTRL + F for searching within the current context, e.g. channel. Commented Sep 3 at 7:38
  • Added to OP that "my use case is a frequently used business app with infinite scrollable content.". In case that matters. Commented Sep 3 at 8:56
  • @GabrielSmoljar: "The "/" does unfortunately not work with keyboard layouts that does not have it without modifier key, e.g. Nordic." What's the problem with modifier keys? CTRL + F requires a modifier key (CTRL) as well...
    – Heinzi
    Commented Sep 3 at 10:20
  • 3
    / is the "Quick find" shortcut in Firefox. Unfortunately GitHub also breaks that shortcut, so you're not the only one.
    – Yay295
    Commented Sep 3 at 12:26
5
  • When you use shortcut keys, you need to make sure they don't interfere with screenreader shortcut combinations.

  • Also, as it's been pointed out several times already, Ctrl+F is already in use.

  • But if you do it anyway, you need to make sure that the change is communicated to all users, including information on how to activate the original Ctrl+F function.

  • WCAG 2.1.4: Character Key Shortcuts

  • WCAG 3.3.2: Labels or instructions

1
  • 1
    Thanks! Philosophical issues aside, it is good to know that overriding shortcuts violates WCAG. Commented Sep 4 at 18:01
4

Depends on your definition of "acceptable", but if it means "done by a major web app vendor"; you should note that Google Sheets (Googles web spreadsheet app, which is extremely widely used) indeed hijacks Ctrl+F to launch in-app search widget instead of site search.

2
  • Also Google Docs. Commented Sep 5 at 6:59
  • The reason they do this is because they use custom rendering where not all of the text content is visible to the browser, they implement it manually just to "un-break" the experience. Same with e.g. GitHub code views, they (approximately) only render lines that are on screen, but user expectation is ctrl+F works on the whole "document".
    – Kroltan
    Commented Sep 5 at 15:42
3

In general I agree with other answers here that CTRL+F should not be redefined. However, you mentioned that this is specifically for infinite scrolling content. In that specific case, redefining CTRL+F may actually help fulfill the user's expectation better.

I have on occasion visited a site with dynamic-loading, infinite scrolling content, scrolled down to load some additional content, and then come back to that site later. If I remember a word or phrase that I wanted to find again, my first instinct would be to hit CTRL+F and type in that word. BUT if the section I remembered is further down the "page" and hasn't yet been retrieved, the search finds no hits, and I'm left wondering if my memory is faulty. So a hijacked CTRL+F that also searches the server for unrendered parts of the page may help in that case.

That said, plenty of people, myself included, consider infinite scrolling to be a terrible design pattern. The fact that hijacking native browser functions may improve the experience is really a good example of why it's such bad behavior in the first place.

1
  • Thank you for your answer. Upon reflecting on it I think that CTRL + F may help in the case of poorly implemented infinite scrolling content. The right solution is prerhaps, to restore infinite scrolling content from cache when returning to a the page. In that case native CTRL + F will work as expected. Commented Sep 6 at 14:59
2

While I agree with GWv's answer, you may want to consider this alternative. I recall using a site that hijacked the CTRL+F feature by showing their own search dialog, but at the same time had a message in thier dialog saying to press CTRL+F again to access the regular browser Find feature. So by pressing CTRL+F twice you could get to the browser Find.

I could be wrong, but I believe it was the Stripe Documentation that did this. However, if you go to the documentation today, you'll see that they use the / to access their search. I have seen more and more websites (including YouTube) use the / key to put focus onto the application's search feature.

Edit: I was looking at the wrong Stripe documentation, the API documentation still has the behaviour I described above. But furthermore, they even have a checkbox to disable thier find dialog from opening on CTRL+F in the future.

1
  • 1
    / is the "Quick find" shortcut in Firefox. If more and more websites are overriding that, I have to assume they aren't testing on Firefox, or aren't familiar with Firefox's shortcuts.
    – Yay295
    Commented Sep 3 at 12:28
1

No.

People are used to their existing search that works across all websites.

Stripe API documentation overrides CTRL+F behavior and I hate it

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 3 at 10:02
  • 3
    The stripe example that you linked is ironically one of the better ones --- they let you press ctrl+f again to get to the native search, and they also have a little checkbox to the shortcut as part of the search box that pops up. Commented Sep 4 at 4:02
1

What does CTRL+F (usually) do? Thus what do user expect it to do?

It searches for the entered string on the currently open page, jumping to the first occurrence and perhaps even showing all occurrences on the current page.

By hijacking CTRL+F you basically say "we know better what the user wants to do", e.g. "they actually want to focus our app's search box and search there for content that is not rendered on the screen" - and you violate user expectations that way. For the user that thinks "Ah, I just read that interesting article about XYZ somewhere on this page, where was it?" this is NOT what the expected, nor what they wanted. Also in a situation where connectivity has been broken a "native" CTRL+F continues to work (albeit on the cached content only) - your "jump to searchbox" solution doesn't.

I.e. this is a good way to turn off users.

So, if you aim is to impede usability, and discourage users from using your app, this is the way to go (perhaps even consider hijacking left & right click) - otherwise DON'T do it.

1

Web app vs Web site

There is a strong consensus in other answers that for web sites ctrl+f should not be hijacked.

However there is some leeway for content editing applications as webapps (not applicable for normal content presented as "single page application) - for example, it could be appropriate for an app like Excel or Google Sheets; or for a rich web-interface like VSCodium, or for any other case where the web application effectively takes over the role of what would otherwise be a full specialized desktop application, and the browser is just a delivery mechanism.

So the big question is whether your 'rich web app' is closer to a rich webpage of content, no matter if it has some editing (for example, like stackexchange), in which case taking over ctrl-f would be inappropriate, or it's more like MS Office 365, in which case it could be.

0

I agree with the other answers here but wanted to add a small addition. In certain web apps like Azure DevOps the default ctrl+f is used everywhere but if you use ctrl+f while focused in a code view it uses a code specific find. So it may be applicable when you are altering the ctrl+f within a specific scope.

0

I am merely a dev and user and this is merely a personal opinion. I have no experience as a designer whatsoever.

There are times when I am on a website which uses some form of lazy loading, combined with the fact it's slowly "unloading" content which I scrolled out of view such as Microsoft Teams or Discord; mostly instant messaging services which I use through a browser.

Sometimes, as I scroll to a specific part of a conversation history, I attempt to hit Ctrl + F because I want to search for a specific bit of text in that specific part of the conversation. Seeing that the page removed content what was scrolled out of view, that makes perfect sense to me.

But alas, some of these websites got implemented in a way that whenever I attempt to hit Ctrl + F, it would catch it and the input focus would land into their own search feature which would search the entirety of the conversation and not just the specific loaded part which I am currently looking at. And I must admit it does make me give up on using Ctrl + F altogether.

1
  • Now, if you're very keen on still overriding Ctrl + F... Please, at the very least, can I have the leisure of choosing between the overrode version and the real version?
    – Clockwork
    Commented Sep 5 at 7:07
0

Ctrl + K is also a commonly used alternative to Ctrl + F. Examples:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.