Skip to content

feat: Make search usable via keyboard (CTRL + K) #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MoritzWeber0
Copy link
Member

Let users open the search via the CTRL + K keyboard shortcut.

Copy link

netlify bot commented May 7, 2025

Deploy Preview for fipguide ready!

Name Link
🔨 Latest commit 857e35f
🔍 Latest deploy log https://app.netlify.com/sites/fipguide/deploys/681c6c770777f8000934d569
😎 Deploy Preview https://deploy-preview-119--fipguide.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@lenderom lenderom requested a review from therobrob May 8, 2025 06:44
@MoritzWeber0 MoritzWeber0 marked this pull request as draft May 8, 2025 07:02
@MoritzWeber0
Copy link
Member Author

MoritzWeber0 commented May 8, 2025

Have to check the macOS behaviour, it doesn't work with the COMMAND key on macOS

EDIT: Fixed

@MoritzWeber0 MoritzWeber0 added the technical Technical issues, e.g. related to Hugo, HTML, CSS, deployment, etc. label May 8, 2025
@therobrob
Copy link
Member

Is it that common to open search via CTRL + K (i didnt know it)? Some other websites (like github.com itself) uses / to open search bar.

@MoritzWeber0 MoritzWeber0 marked this pull request as ready for review May 8, 2025 08:34
@MoritzWeber0
Copy link
Member Author

Is it that common to open search via CTRL + K (i didnt know it)? Some other websites (like github.com itself) uses / to open search bar.

At least all common frontend frameworks use it on their websites:

On GitHub, CTRL + K also works for the search.

CTRL + K is usually the shortcut for omnibox, i.e., using the search bar of the browser of the page. It got common to overwrite the shortcut to implement a custom search functionality.

@therobrob
Copy link
Member

On these websites, it works from every page; we only have the search on home. I don't want to block the feature, but I wonder if it adds much value to our website.

Another question: is this shortcut also supported by the A11Y community? Is it also supported by screen readers, or are there other shortcuts here?

@MoritzWeber0
Copy link
Member Author

MoritzWeber0 commented May 8, 2025

On these websites, it works from every page; we only have the search on home. I don't want to block the feature, but I wonder if it adds much value to our website.

It does. You can navigate on the page via keyboard more easily. My usual workflow (that I use for other pages as well): Open the website via the URL, use CTRL + K to search and navigate to the target page.

But nevertheless, page search on the whole website would be even better and I already created #120 for it.

Another question: is this shortcut also supported by the A11Y community? Is it also supported by screen readers, or are there other shortcuts here?

Nothing that I have knowledge about, but ChatGPT summarized it as:

  • Ctrl + K is generally accepted in web apps as a convention for search or command bar, but it is not officially standardized in accessibility guidelines like WCAG.
  • Screen readers do not reserve Ctrl + K for their own functions, so it's usually safe to use as a custom shortcut.
  • Developers are encouraged to provide accessible alternatives (like a visible search box or accessible buttons).

I'd argue that it improves accessibility since it's easier to navigate via keyboard.

@lenderom
Copy link
Member

lenderom commented May 8, 2025

Docusaurus also uses this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical Technical issues, e.g. related to Hugo, HTML, CSS, deployment, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants