Add a registry model and view for managing keyboard shortcuts.

Review Request #13591 — Created Feb. 29, 2024 and submitted — Latest diff uploaded

Information

Ink
master

Reviewers

Part of Ink's focus on accessibility is formalizing support for keyboard
shortcuts. Components will be able to easily list keyboard shortcuts
that trigger an element, providing both a visual indicator and ARIA
information for screen readers.

Keyboard shortcuts will be registered in the new
KeyboardShortcutRegistry model, which takes a key, modifier flags, and
a callback handler, and registers it for quick access.

A corresponding KeyboardShortcutRegistryView can be attached to an
existing element and a registry model to invoke the handlers when those
keys are pressed.

Once attached, a registry view can be found on any ancestor DOM element
by using KeyboardShortcutRegistryView.findNearestRegistryView.
Similarly, a nearest registry can be found using
findNearestRegistry().. This makes it easy for components to
automatically register with the correct registry.

The plan is to eventually let the view pop up a dialog when ? is
pressed, to show the available keyboard shortcuts. This has been a
long-standing plan for Review Board, and with these new foundational
classes, we'll be able to offer this.

Unit tests pass.

Commits

Files

    Loading...