2

I am looking to use javascript to trigger focus on a search field inside a web page when a keyboard shortcut is pressed.

People dislike it when ctrl-f is overridden, because it prevents the user from using the browser's in-page search feature.

What is the most popular shortcut used for custom in-page search on a web site?

By using the most popular shortcut observed around the web, I hope to make it easy for people to remember the shortcut. It is also less likely to clash with other shortcuts introduced by browsers in the future, since this would break the functionality implemented by major web sites.

2
  • Does it really need a shortcut key? Why not make it the 1st item in the Tab order so that the user gets straight to it that way (well, maybe 2nd in the Tab order, as you probably want a skip-link as the first).
    – JonW
    Sep 20, 2022 at 8:28
  • @JonW because I don't want search to be the first thing someone thinks of when they hit the page, so I don't want them to be distracted by a flashing cursor Sep 20, 2022 at 9:56

2 Answers 2

1

I think the closest sign is the / sign. It works on many popular websites like Google, Facebook, JIRA, etc. Some websites use the S character, but / is more common. As far as I know, the reason to use that character comes from vim unix editor.

One thing though: I know this works in Chrome (just tested it), but it doesn't work in Safari. And in Firefox it works, but instead of focusing on the search bar, it just opens the default search box (just like when you use CTRL +F). Firefox has addons for this behavior, and they use the cmd+space (guess it's CTRL+SPACE on Windows).

All things considered, since Chrome is more widely adopted and they use the / sign, I'd say using this character is the safest choice.

2
  • 1
    I'm not sure what you're referring to in your second paragraph when you say "I know this works". Both / (on e.g. youtube.com) and CMD-F work in Safari. Sep 12, 2022 at 17:46
  • I tested it fast in Facebook and Google and didn't work, so I assumed it didn't work on Safari. But it could also be an OS thing (I'm using Catalina, which is a bit old). If you tested and it works, then even better! :)
    – Devin
    Sep 12, 2022 at 17:49
-1

Try Command+F or Control+F keyboard shortcuts On most web pages, word processors, and other programs, you can use the keyboard shortcut Command + F on a Mac , or Control + F on Windows to find what you need.

1
  • This will look for content within the active page or screen. The question is about a command that focus on the search box so users can search anywhere in a given environment
    – Devin
    Sep 15, 2022 at 18:32

Your Answer

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

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