0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Keyboard shortcuts help overlay. Press ? to see all bound shortcuts.
Description
The <short-cuts> component provides a keyboard shortcuts help overlay, similar to GitHub's ? shortcut or Gmail's shortcut reference. Place it once in your layout and press ? to see all currently bound keyboard shortcuts grouped by source.
Basic Usage
Drop <short-cuts> anywhere on the page. It renders nothing visible — it binds the ? hotkey and exposes show() for a visible button, so pointer and touch users can reach the list too. Press ? on this page to try it (it's already included in the layout).
Basic usage
123456789
<!-- Place once per page, typically in your layout --><short-cuts></short-cuts><!-- A visible way in for pointer and touch users --><buttontype="button"id="open-shortcuts">Keyboard shortcuts</button><scripttype="module">document.getElementById('open-shortcuts') .addEventListener('click', () =>document.querySelector('short-cuts').show());</script>
Key combo that toggles the dialog. none turns the shortcut off. Changes are applied live.
data-label-title
Keyboard shortcuts
Dialog heading, which also names the dialog
data-label-general
General
Group holding the component's own shortcut
data-label-self
Show keyboard shortcuts
Label of the component's own shortcut
data-label-close
Close
Close button name
Remapping or Turning Off ?
? is a single printable character, so under WCAG 2.1.4 (Character Key Shortcuts) users must be able to turn it off or remap it. They might be using speech input or a keyboard layout where ? is awkward. Set hotkey to a combo with a modifier, or to none, and give the dialog a visible button.
Remap or disable
12345
<!-- Remap to a modifier combo --><short-cutshotkey="alt+shift+k"></short-cuts><!-- Turn the hotkey off; open it from a button instead --><short-cutshotkey="none"></short-cuts>
Users can also turn every single-character shortcut off at once with the Single-Key Shortcuts toggle in <settings-panel> (Accessibility), which sets <html data-char-shortcuts="off">. Authors can set that attribute in markup too. While it is off, ? no longer opens the dialog, and the dialog leaves out every unscoped character-key shortcut (its own ? and data-hotkey actions such as /), because none of them fire. Shortcuts with Ctrl, Cmd or Alt, and data-hotkey-scoped ones, are still listed.
JavaScript API
Member
Type
Description
show()
method
Open the dialog, rebuilding the list from the current sources
close()
method
Close the dialog
toggle()
method
Open when closed, close when open
open
boolean (read-only)
Whether the dialog is open
hotkey
string | null (read-only)
Active combo, or null when hotkey="none"
shortcuts
get/set
Override list { [group]: [{ label, shortcut }] }. When set, it replaces the registry sources (the component's own shortcut is still listed) and re-renders an open dialog. Set null to go back to the registries. Fires short-cuts:shortcuts-changed with { shortcuts, source }.
When opened, the overlay reads two registries, unless the shortcuts property is set. The command registry (window.__commandRegistry) supplies registered commands that have a data-shortcutattribute, grouped by data-command-group. The hotkey-action registry supplies every non-<kbd> element with data-hotkey. It is labelled by data-hotkey-label (or its text) and grouped by data-hotkey-group, which defaults to "Page Actions".
With commands
123456789101112131415
<!-- Shortcuts overlay discovers data-shortcut bindings automatically --><short-cuts></short-cuts><!-- These shortcuts appear in the overlay --><buttondata-command="Toggle Dark Mode"data-shortcut="meta+shift+t"> Dark Mode</button><buttondata-command="Save Draft"data-shortcut="meta+s"> Save</button><!-- data-hotkey actions are listed too --><buttontype="button"data-hotkey="alt+p"data-hotkey-label="Print preview"> Print</button>
Shortcut Sources
Source
How it appears
[data-command][data-shortcut] elements
Label from data-command, group from data-command-group
[data-hotkey] elements (not <kbd>)
Label from data-hotkey-label or text, group from data-hotkey-group (default "Page Actions")
shortcuts property
Replaces both registries while set
The component's own hotkey
"Show keyboard shortcuts" in the "General" group (left out when hotkey="none")
Keyboard Support
Key
Action
? (or the hotkey combo)
Open/close the shortcuts overlay
Escape
Close the overlay
The hotkey does not fire when focus is inside an input, textarea, or content-editable element.
Accessibility
Opens as a modal <dialog> named by its heading (aria-labelledby), with a visible close button
Escape, the close button or a backdrop click closes it, and focus returns to where it was
Each group is a <section> with an <h3>, and rows form a <dl> (action in <dt>, keys in <dd>), so screen-reader users can jump between groups by heading
Key badges show platform glyphs (⌘, ⇧ on Mac; Ctrl, Shift elsewhere) and carry visually hidden spoken names ("Command K", "Shift ?")
The hotkey can be remapped or turned off (WCAG 2.1.4), and it honours the site-wide Single-Key Shortcuts preference (<html data-char-shortcuts="off">)
In forced-colors mode the dialog keeps a visible border
Native accesskey shortcuts are not read or listed; bind shortcuts with data-hotkey so they appear here