Shortcuts: a way forward? #15190
Labels
[Feature] Rich Text
Related to the Rich Text component that allows developers to render a contenteditable
[Feature] Writing Flow
Block selection, navigation, splitting, merging, deletion...
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
Shortcuts have always been a bit problematic:
Examples:
Ctrl+B
may change depending on the language.Ctrl+Alt
combinations may conflict with assistive technologies, see Keyboard shortcuts that use theaccess
modifier don't work with VoiceOver #11154.Ctrl+A
work for keyboards without anA
key?Ctrl+D
is sometimes used as an alternative toDelete
, see Rich Text: Treat ctrl+d as delete #15019.Ctrl+Y
may or may not be implemented as redo, depending on the OS and browser, see Reintroduce support for meta+Y shortcut #8921.Solution: we need to look at intention instead of trying to interpret key combinations.
Key interpretation must be removed if it includes at least one key that is not universal. For example:
A
,B
,C
...In editable areas (
textarea
andcontenteditable
), theInputEvent.inputType
can be used. For example:formatBold
means the user wants to format something bold.The problem is that this cannot be used for block selection. When a modifier key is pressed (
Ctrl
,Cmd
orAlt/Option
), we could insert an invisibletextarea
with two characters and place the caret in the middle. Attachinput
andselectionChange
event listeners. With these we can see if the user wants to select all content (check selection), undo or redo something (historyUndo
,historyRedo
), or delete something (deleteContentForward
). If the modifier key is released again, restore focus to the block wrapper.There one thing that is hard to resolve however: documentation for these shortcuts. We are completely unaware which key combination would be the right one for e.g. bolding text. We could make the combination text translatable though, and note in the shortcut modal that it may not be accurate if your OS language is different or if you have mapped the shortcuts.
Thoughts? Cc @afercia.
The text was updated successfully, but these errors were encountered: