Accessibility · Component reference
Keyboard guide
A focused help dialog with clear navigation instructions and no global shortcut collisions.
Try the live exampleResearch and our take
Our recorded research compared reader preferences and accessibility tools across several projects. For this component, these observations informed Starlit’s approach:
- WP Accessibility: Skip destinations, focus visibility, image descriptions and controls for presentation. Our decision: Keep native navigation semantics and display authored image descriptions accurately.
Starlit wrote the shared controller, scoped content adapters and component modules presented here. The referenced widgets are research sources, not browser dependencies. The component also draws on interface work in EvansWiki and PayCal.
Design reasoning
Explain the interaction where people need it, without inventing shortcuts that collide with typing or assistive tools.
- Start with the person’s task and the barrier they may encounter.
- Use for a page with several keyboard operated controls. Author help that matches the actions actually available.
- Keep the ordinary content and action usable before adding enhancement.
- Open help using only the keyboard. Traverse its controls, use its content focus action, reopen and dismiss with Escape.
Usage pattern
Use for a page with several keyboard operated controls. Author help that matches the actions actually available.
Impact and tradeoffs
A concise guide can reduce uncertainty. Stale or inaccurate shortcut instructions create another barrier.
Accessibility solutions
Use a named native dialog with a visible close action. This component adds no global single letter shortcut.
Build accessible source content first. Personal preferences supplement semantic HTML, useful names, keyboard access and visible focus.
HTML
A concrete usage example. Host these assets on your own origin if you adapt the pattern. Read the source and credits before reuse.
<link rel="stylesheet" href="/open-ui/accessibility/shared/content.css">
<script type="module"
src="/open-ui/accessibility/components/keyboard-help/index.js"></script>
<article id="reading" data-sdou-a11y-content data-default-theme="dark">
<div data-sdou-a11y-prose>
<h2 id="begin">Begin with a clear purpose</h2>
<p>Readable text and useful controls belong together.</p>
<h2 id="details">Consider the details</h2>
<p>The page should remain usable before any enhancement loads.</p>
</div>
</article>
<sdou-keyboard-help target="#reading"
storage-key="example.keyboard-help.v1"></sdou-keyboard-help>CSS
This is the component stylesheet used inside its Shadow DOM. The shared ui.css supplies its base controls and content.css adapts the reading region. An empty component stylesheet deliberately inherits the shared UI.
.key-list {
margin: 0;
display: grid;
gap: 16px;
}
.key-list > div {
display: grid;
grid-template-columns: 104px 1fr;
gap: 16px;
align-items: start;
}
.key-list dt {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.key-list dd {
margin: 0;
font-size: 0.9375rem;
color: var(--sdou-ax-muted);
}
kbd {
font:
0.8125rem/1.5 ui-monospace,
monospace;
border: 1px solid var(--sdou-ax-line);
border-radius: 6px;
padding: 3px 7px;
color: var(--sdou-ax-ink);
background: var(--sdou-ax-bg);
}
@media (max-width: 360px) {
.key-list > div {
grid-template-columns: 1fr;
gap: 8px;
}
}
JavaScript
This is the actual component module used by the live example. Imports, the base class and shared preferences are dependencies. Keep the component folder and shared folder in their relative positions.
import { A11yComponent } from "../../shared/base.js?v=sdou20261029";
class KeyboardHelp extends A11yComponent {
static styles = new URL("./component.css?v=sdou20261029", import.meta.url).href;
render() {
this.mount(
"A clear way around.",
"Use the browser and native controls you already know. This component adds no global letter shortcuts.",
'<dl class="key-list"><div><dt><kbd>Tab</kbd></dt><dd>Move to the next control.</dd></div><div><dt><kbd>Shift</kbd> <kbd>Tab</kbd></dt><dd>Move to the previous control.</dd></div><div><dt><kbd>Enter</kbd></dt><dd>Open a link or activate the focused button.</dd></div><div><dt><kbd>Space</kbd></dt><dd>Toggle a switch or activate a button.</dd></div><div><dt><kbd>←</kbd> <kbd>→</kbd></dt><dd>Adjust a focused range control.</dd></div><div><dt><kbd>Escape</kbd></dt><dd>Close this dialog and return to its button.</dd></div></dl><details><summary>Browser reading controls</summary><div class="group-body"><p class="hint">Use your browser zoom controls to enlarge the whole page. Use your device screen reader, magnifier or voice controls as needed. These components work alongside them.</p></div></details><button type="button" class="button secondary" data-skip>Move focus to the reading area</button>',
{ dialog: true, launcher: "Keyboard guide", reset: false },
);
}
initialize() {
this.on(this.q("[data-skip]"), "click", () => {
this.q("dialog").close();
queueMicrotask(() => {
this.target.tabIndex = -1;
this.target.focus();
this.target.scrollIntoView({ behavior: "auto", block: "start" });
});
});
}
}
customElements.define("sdou-keyboard-help", KeyboardHelp);
PHP integration
In your own application, PHP can render this HTML on the server. Here, the example is escaped text only. The library has no PHP runner or execution endpoint. The browser owns the interaction.
<?php
// Server render trusted structure and escape authored text.
// PHP does not implement or save these browser preferences.
declare(strict_types=1);
$title = 'A readable article';
$paragraph = 'Your authored content goes here.';
$e = static fn (string $value): string =>
htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
?>
<link rel="stylesheet" href="/open-ui/accessibility/shared/content.css">
<script type="module"
src="/open-ui/accessibility/components/keyboard-help/index.js"></script>
<article id="reading" data-sdou-a11y-content data-default-theme="dark">
<div data-sdou-a11y-prose>
<h2 id="begin"><?= $e($title) ?></h2>
<p><?= $e($paragraph) ?></p>
</div>
</article>
<sdou-keyboard-help target="#reading"
storage-key="example.keyboard-help.v1"></sdou-keyboard-help>
API and dependencies
- Element
sdou-keyboard-help- target
- A selector for the content region. Use a unique ID. Components sharing a target share its controller.
- storage-key
- A stable key for this project. Use the same key for controls targeting the same region. Preferences stay in browser storage when available.
- Content
data-sdou-a11y-contentmarks the target;data-sdou-a11y-proseidentifies reading copy. Usedata-default-theme="dark"for a dark initial and reset preference.- Event
sdou:a11y-changeis dispatched on the target withpreferences,paletteandreducedMotionin its detail.- Dependencies
- Modern JavaScript modules, custom elements, Shadow DOM and native form controls. Dialog, speech, clipboard and fullscreen support depend on the feature and browser.
Read shared/base.js · Read the preference controller · Read the content adapter · Read the shared control styles
Testing and limitations
Open help using only the keyboard. Traverse its controls, use its content focus action, reopen and dismiss with Escape.
The original library validation records automated rule checks, 320px reflow, enlarged text, text spacing, state persistence and relevant functional checks. Unresolved automated Shadow DOM reference checks are recorded separately from browser dialog checks. These historical results are not a new audit of every integration.
Production review still needs assistive technology, touch, zoom, custom styles and representative content. See our testing scope and known gaps. Report a barrier to Starlit.