Repository navigation
Description
Follow-up to #76135.
What problem does this address?
@wordpress/ui does not have a consistent contract for presenting keyboard shortcuts and exposing them to assistive technology.
Actually reacting to keyboard shortcuts is outside the scope of UI components and remains the consumer's responsibility. This issue focuses on using the representations provided by @wordpress/keycodes consistently across @wordpress/ui:
- Applying
aria-keyshortcutsto the interactive element associated with the action. - Displaying a platform-appropriate shortcut.
- Providing a localized, human-readable description for assistive technology.
- Using a consistent shortcut prop shape across higher-level components.
A single logical shortcut currently needs three related representations:
- A visual representation, such as
⌘SorCtrl+S. - A human-readable label, such as
Command S. - An
aria-keyshortcuts-compatible value, such asMeta+S.
@wordpress/keycodes provides separate displayShortcut, shortcutAriaLabel, and ariaKeyShortcut helpers. PR #74205 intentionally did not ship a combined formatter because the existing helpers do not always accept the same input syntax.
The current component patterns are incomplete:
IconButtonacceptsdisplayShortcutandariaKeyShortcut. It renders the visual value in its tooltip and setsaria-keyshortcuts, but does not provide an explicit accessible description.Buttonhas no shortcut-specific API. Adding one would either couple this low-level component toTooltipor force a particular visual placement.- The new
Menuin #79560 demonstrates manually pairingaria-keyshortcutswith a visual suffix. This wiring should be consistent and reusable across menu items.
The aria-keyshortcuts specification makes clear that the attribute advertises a shortcut but does not implement it. It also recommends making shortcuts discoverable visually. The APG keyboard interface guidance says shortcuts should augment normal keyboard access and that key assignments should be revealed on their target elements.
Following the discussion in #76135, @wordpress/ui should also provide an explicit accessible description instead of relying only on assistive technology support for aria-keyshortcuts. This can be implemented with aria-describedby pointing to visually hidden text such as "Keyboard shortcut: Command S".
Proposed approach
Expand the existing IconButton shortcut shape with a third value containing the human-readable shortcut label, typically generated with shortcutAriaLabel.
When a higher-level component receives this shortcut metadata, it should:
- Apply the ARIA-compatible value through
aria-keyshortcuts. - Render the visual value as presentational content.
- Render a localized, visually hidden shortcut description.
- Merge that description into any consumer-provided
aria-describedby. - Leave registration and keyboard event handling to the consumer.
Consumers must also keep the external shortcut handler synchronized with the component's enabled or disabled state.
Tasks
- Agree on a common shortcut prop shape and naming for higher-level
@wordpress/uicomponents. IconButton: Improve keyboard shortcut accessibility #80402 - Expand
IconButtonshortcut support with a human-readable description and visually hiddenaria-describedbycontent. IconButton: Improve keyboard shortcut accessibility #80402 - Preserve consumer-provided
aria-describedbyvalues inIconButton. IconButton: Improve keyboard shortcut accessibility #80402 - Add a
ButtonStorybook example showing the complete manual composition withTooltip,aria-keyshortcuts, and an accessible description. @wordpress/ui: Add Button Storybook example for keyboard shortcut composition #80353 - Explore a dedicated
ShortcutButton-style component—name TBD—that composesButtonandTooltipwithout adding aTooltipdependency toButton. ShortcutButton: Add UI component #80407 - Add equivalent shortcut support to
Menu.Item, rendering the visual shortcut after the existingsuffix. Menu: Add UI component #79560 - Audit
Menu.LinkItem,Menu.CheckboxItem,Menu.RadioItem, andMenu.SubmenuTriggerfor the same contract. Menu: Add UI component #79560 - Ensure visual shortcut strings retain their logical key order in RTL interfaces. (done in IconButton: Improve keyboard shortcut accessibility #80402 , @wordpress/ui: Add Button Storybook example for keyboard shortcut composition #80353 and Menu: Add UI component #79560)
- Add tests covering the visible representation,
aria-keyshortcuts, accessible description, existing descriptions, and disabled states. (done across PRs) - Update component documentation to clarify that shortcut props do not register or handle keyboard events. (done across PRs)
- Manually verify the resulting descriptions with representative screen reader/browser combinations. (done across PRs)
- Make the shortcut handling (types, potentially some implementation too) a shared util and add it back to
IconButtonIconButton: Improve keyboard shortcut accessibility #80402
Out of scope
- Registering, listening for, remapping, or resolving conflicts between shortcuts.
- Adding a generic visual
Shortcutcomponent without a concrete additional use case. - Reintroducing a combined
@wordpress/keycodesformatter without resolving the input-format limitations discussed in #74205.
Related history
- UI readiness discussion and initial direction
- Updated component-specific plan
- Add
ariaKeyShortcutto@wordpress/keycodes - Add
IconButtonto@wordpress/ui - Add
Menuto@wordpress/ui - Earlier legacy
Shortcutaccessibility implementation - Screen reader limitations of
aria-labelon non-interactive shortcut content - Discussion of platform-native visual shortcut notation
Activity
ciampo commentedon Jul 17, 2026
Update:
ButtonStorybook example updated in @wordpress/ui: Add Button Storybook example for keyboard shortcut composition #80353 (thank you, @shrivastavanolo 🙏 )IconButtonwith the same shortcut functionality (and makes it a shared util, which will be picked up byMenuand potentiallyShortcutButton)shortcutsupport for theMenucomponent, as per the specs above;ShortcutButtoncomponent (stacked on top of theIconButtonPR).ciampo commentedon Aug 10, 2026
Update:
ciampo commentedon Aug 19, 2026
Update: we're closing #80407 since it may too early to have a dedicated high level component for that usecase.
Instead, the work will continue in #81826 to expose the smaller utilities that consumers of the package can use when adding keyboard shortcut support to
@wordpress/uicomponents.