-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add a preference to allow a custom go to toolbar
keyboard shortcut
#59213
Comments
My instinct would be to allow customizing virtually any keyboard shortcut, and thus have it live in the existing Keyboard shortcuts modal: This would be similar to Macos, in the Settings > Keyboard shortcuts section: The above GIF shows the MacOS shortcuts panel, where you have to double click a particular shortcut to customize it. I feel like we could take a simpler route there, and simply have each shortcut being an input field, so you could just type out your preferred shortcut and press Enter to set it. |
One challenge that may suggest starting with just a single keyboard shortcut — the most important one, go to toolbar, as you suggest — is that when you have more than one keyboard shortcut you likely need some conflict detection to see whether a chosen shortcut is already in use. That's less of a case when only a single one is customized. So by starting with just this one, we could potentially lay the plumbing for broader customization, address an accessibility concern, and make progress. It's not clear to me that putting it in "Accessibility" is useful, though; would it make sense to have a "Shortcuts" section if it only contained that one shortcut? |
Thinking more about this, and in order to land this important piece, and since there would only be a single shortcut in a new "Shortcuts" section to start, the accesibility section does seem the right place to put this after all. |
I added it to "Accessibility" as we were discussing it in the context of accessibility. It felt a bit weird to have only one of the options editable in the existing modal, and it felt a bit weird to have only one option in a new place. I figured we could move it later once we start adding more, but it will probably be a while before we can build the infrastructure and refactor the code to support better keyboard shortcut customization. |
Adding this particular shortcut is useful for unblocking #59199, so I figured we'd be able to do an ad-hoc solution for remapping this particular shortcut and think about the input mechanism for registering more shortcuts (and detecting conflicts) when we add a second shortcut. There is the opportunity for someone to reset this to an existing hard-coded shortcut, but I think it's okay to trust the user (for this first iteration) to not do that. If they do, they'll see something is wrong and be able to reset the shortcut to the default value to fix the issue. |
Here's a rough Figma prototype that shows a few more things on a happy path.
There are a few things that I'd like changed from this rough prototype.
|
@ajlende and I have been talking about the UX flow for this. Here's some rationale and justification for each of the design decisions: Input Activation: Enter or Click to begin editing vs Edit buttonTo begin editing a shortcut, we could offer an Edit button or allow an enter keypress/click on the input to begin recording the shortcut keypresses. Initially, I thought Edit buttons would be best as this is the standard process for keyboards and screen readers, but it begins to break down when working with shortcut inputs since we need to override standard keycontrols while in editing mode. For example, Escape would typically cancel editing, but Escape could be part of a valid keyboard shortcut keypress. Also, having an edit button for one shortcut isn't cluttering, but once we allow this pattern for all shortcuts, it becomes quite overwhelming for the UX. Also, if one were to edit all their shortcuts, many edit buttons would greatly increase the number of clicks/keypresses to change all the shortcuts. The shortcuts can't be an open input field, otherwise it becomes a keyboard trap once it is tabbed to. With all this in mind, to begin editing the input, you'll have to press Enter. This is a non-standard way to begin editing a field, but it also can't have a standard way of exiting the input, as Escape and Tab are both a valid shortcut keypresses. Escape can't clear the input and Tab can't tab out of it, otherwise you can't use Escape or Tab within you shortcut. Because of this, I think we're justified in offering a short learning curve: Enter to begin editing the shortcut, Enter again to save. Other inputs within the Preferences modal save at the time they are modified, so saving after edit also follows the existing pattern of the context. Recording the shortcut value - Key by Key Input (normal typing) vs ChordedKey by Key Input: Allow for keys to be pressed in succession, just like typing in a normal input field. Key by Key
Chorded:Faster to understand and undo if you make a mistake. For the chorded input, if I press Shift, release, then J, I will end up with J as my shortcut. Maybe I try Escape to clear it and see the J overwritten with Escape. At this point, I would try the chorded input of Shift + J at the same time to get to the shortcut I want. I don't have to save my error and start again on a typo. The simpler error correction is quite worthwhile here to avoid larger frustrations. Errors are likely to happen with either method. A user faced with a key by key error is going to be frustrated. An error on the chorded input is just a quick lesson in how the input works. With how poor the UX is to undo a mistake on the key-by-key, I think a chorded input is the better option. Resetting FieldsAfter a new shortcut is entered, a reset button is offered for that input. |
One more thing about conflicting shortcuts is that some shortcuts may need to be contextual. The We wouldn't want Potentially we could separate the global shortcuts from the contextual ones. This particular contextual shortcut can be unset initially. |
Looking into this issue I'd tend to think it moves from some assumptions that don't sound entirely correct to me. The behavior of these shortcuts has been discussed in many other issues and PRs but I'd like to point out a couple considderations one more time.
That may be true for document editors but it's not true in all software. Document editors like Word or Google Docs, whether they are operating system apps or web abbs doesn't matter, are meant to edit a document. Instead, the Gutenberg editor is a web app where the native behavior of Tab and Shift+Tab needs to be preserved. I think #59199 is a good compromise and does what Google Docs. Indentation with Tab / Shift+Tab works when the cursor is at the start of the selection. Otherwise, it preserves the nativ ebehavior.
I'd argue that this is an incorrect assumption. For ages, cm/Ctrl + k has been an industry standard to insert a link in most of the web editors I can think of. It's a standard since more than 20 years. Command palettes came way after and if htey use the same shortcut they're just doing it wrong. |
I'm not sure I follow this part entirely:
and
What's the difference, then? If they are all web apps, what's the rationale for stating so strongly that |
I fixed a typo
There is large disagreement on whether the Gutenberg editor is closer to a text document app or a web app based on form controls. To me, it's not a text document editor. The editor UI makes use of form controls: inputs, selects, buttons, contenteditable elements that are equivalent of textareas etc. As such, the Tab key needs to be preserved to its native functionality that is: navigating through interactive controls. Any other usage of the Tab key on a page that is basically a form-based web app would be totally unexpected. |
What problem does this address?
There are a few instances in the block editor where industry-accepted shortcuts conflict with existing editor shortcuts, for example:
shift ⇧ + tab
to unindent would conflict with the current keyboard shortcut to go to the current block's toolbar. (see List: allow indenting with Tab #45404)cmd ⌘/Ctrl + k
is commonly accepted to launch the equivalent to the editor's command palette, but it conflicts with the shortcut to add/modify links (see Command Palette: Global command shortcut conflicts with existing shortcut #51737)What is your proposed solution?
Adding a new preference under the accessibility tab allowing a custom
go to toolbar
keyboard shortcut would help prevent the interference between (un)tabbing to (un)indent in the List block and unblock #59199, as seen in the mockup below created by @ajlende:Possible improvements:
Enter ↵
andEsc
to accept and cancel, respectively, following the a11y pattern suggested in the List View inline name editing PR.This issue is a first step to enabling more custom shortcuts, as described in #3218.
The text was updated successfully, but these errors were encountered: