Skip to content
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

Use ALT+S to trigger search #1101

Closed
wants to merge 1 commit into from
Closed

Use ALT+S to trigger search #1101

wants to merge 1 commit into from

Conversation

brycefisher
Copy link
Contributor

As currently implemented, any time the S key is pressed outside of the search interface, that keystroke is intercepted and the search interface is displayed. This causes problems when interactive widgets are embedded on the page (as raised in #1020).

This PR instead switches to ALT+S so that interactive widgets can be displayed on the page (and more generally, makes the S key available to JavaScript running on the page). Rationale for ALT+S:

  • Current implementation uses 'S' -- so we want to stay close to that
  • 'S' is a great mnemonic device for search
  • Windows desktop applications uses CTRL+S for save, which would likely cause the page to be downloaded
  • MacOS desktop applications use CMD+S (or event.keyMeta in javascript) to save
  • Ubuntu follows one of these conventions (can't remember which offhand...maybe both?)
  • ALT+S appears not to be in widespread usage on either of those platforms
  • ALT+S is only key-stroke different than current implementation

As currently implemented, any time the S key is pressed outside of the search interface, that keystroke is intercepted and the search interface is displayed. This causes problems when interactive widgets are embedded on the page (as raised in #1020).

This PR instead switches to ALT+S so that interactive widgets can be displayed on the page (and more generally, makes the S key available to JavaScript running on the page). Rationale for ALT+S:

 * Current implementation uses 'S' -- so we want to stay close to that
 * 'S' is a great mnemonic device for _search_
 * Windows desktop applications uses CTRL+S for save, which would likely cause the page to be downloaded
 * MacOS desktop applications use CMD+S (or `event.keyMeta` in javascript) to save 
 * Ubuntu follows one of these conventions (can't remember which offhand...maybe both?)
 * ALT+S appears not to be in widespread usage on either of those platforms
 * ALT+S is only key-stroke different than current implementation
@ehuss
Copy link
Contributor

ehuss commented Nov 23, 2019

Thanks for the PR! I don't think we can make this change, because Alt-S is used on Windows to access menus.

I imagine we could make this a configuration option. Even better: is it possible to disable/override the S hotkey when your widget is active or has focus?

@brycefisher
Copy link
Contributor Author

brycefisher commented Nov 23, 2019 via email

@ehuss
Copy link
Contributor

ehuss commented Dec 4, 2019

Yea, it would go in the search option. I'd avoid embedding javascript in the config.
Is it not possible to just disable the hotkey in more situations? Like if any input field has focus?

@brycefisher
Copy link
Contributor Author

That's a promising idea to explore...if the event.target is a form element, then bail out...That might work!

@ehuss
Copy link
Contributor

ehuss commented Mar 9, 2020

I'm going to close since there hasn't been much activity for a while. If you want to pick this back up, feel free to open a new PR!

@ehuss ehuss closed this Mar 9, 2020
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this pull request Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants