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…
Assigns a browser keyboard shortcut (modifier plus one key) that focuses or activates an element. Hard to discover and prone to clashes; VB's data-hotkey is usually the better choice.
Overview
The accesskeyattribute asks the browser to create a keyboard shortcut for an element. The user holds the browser's access-key modifier and presses the assigned key. The browser then focuses the element (form fields) or activates it (links and buttons). You choose the key; the browser chooses the modifier.
The key for the shortcut. Letters are case-insensitive. Use a letter or digit that exists on your users' keyboards.
Space-separated characters, e.g. s n
The HTML spec allows a list of fallback keys; the browser should use the first one it can assign. Support varies, and MDN documents a single character only. Use one character.
"" or absent
No shortcut. This is the default.
Modifier keys
The modifier depends on the browser and platform. You cannot change it. For accesskey="s":
Browser
Windows / Linux
macOS
Chrome, Edge
Alt+S
Control+Option+S
Firefox
Alt+Shift+S
Control+Option+S
Safari
—
Control+Option+S
Firefox and Safari expose the full combination as element.accessKeyLabel (for example "Alt+Shift+S"). Chromium does not support accessKeyLabel, so a hint you print on the page cannot name the modifier reliably. The demo uses accessKeyLabel where it exists and falls back to the bare key.
Examples
Listing the shortcuts
Browsers show no list of access keys, so tell people what exists. Name the key, not a platform-specific combination, unless you fill it in from accessKeyLabel.
A shortcut list
12345678
<sectionaria-labelledby="keys-heading"><h2id="keys-heading">Shortcuts on this page</h2><p>Hold your browser's access-key modifier and press:</p><dldata-variant="horizontal"><dt><kbd>S</kbd></dt><dd>Search orders</dd><dt><kbd>N</kbd></dt><dd>New order</dd></dl></section>
Showing the real combination where the browser reports it
12345
for (const el ofdocument.querySelectorAll('[accesskey]')) {const kbd = document.getElementById(`key-${el.accessKey}`);// accessKeyLabel: Firefox and Safari. Chromium returns undefined.if (kbd && el.accessKeyLabel) kbd.textContent = el.accessKeyLabel;}
Keys to avoid
Access keys share key space with the browser, the operating system and screen readers. Some combinations that clash on Windows:
Alt+D moves focus to the address bar.
Alt+F and Alt+E open browser menus.
Control+Alt (AltGr) combinations type characters on many European layouts.
When keys clash, browsers resolve it differently: some favour the page, some the browser. Test on the platforms your users have.
In Vanilla Breeze
No styles and no script read accesskey. VB does not convert it, list it or warn about it. The note in src/utils/hotkey-action-init.js that data-hotkey "upscales" accesskey describes the idea, not a conversion: the two attributes are independent.
data-hotkey is VB's shortcut system. You write the full combination (meta+s, /, shift+?); meta becomes Cmd on Apple platforms and Ctrl elsewhere. Bound elements get aria-keyshortcuts unless you set your own. Every action binding is listed in the <short-cuts> dialog, which opens with Shift+? by default (src/web-components/short-cuts/logic.js).
Duplicate data-hotkey bindings log a console.warn in development and the last binding wins (src/utils/hotkey-bind.js). Nothing checks for clashes with browser, OS or screen-reader shortcuts. Multi-key sequences (press G, then D) are not supported.
Accessibility
Discoverability is the main problem. Sighted keyboard users have no built-in way to find access keys. Some screen readers announce the key when the element is focused.
WCAG 2.1.4 (Character Key Shortcuts) does not apply. That criterion covers shortcuts made of a single printable key. An access key always needs the browser's modifier, so it is not a character-key shortcut. For the same reason VB's single-key shortcut preference (data-char-shortcuts="off", set from the settings panel, src/lib/char-shortcuts.js) does not switch access keys off. It only affects data-hotkey bindings such as / or ?.
No aria-keyshortcuts is added. If you want the shortcut announced consistently, set aria-keyshortcuts yourself, or use data-hotkey, which sets it for you. See ARIA states VB styles.
Avoid screen-reader keys. JAWS and NVDA use many Alt and Control combinations. Test with the assistive technology your users have.
Never make an access key the only way in. Every target must also be reachable with Tab and visible navigation.
Gotchas
The modifier is not yours to choose. A printed hint like "Alt+S" is wrong for Firefox and for every Mac user.
Keyboard layouts differ. The character has to exist on the user's keyboard. A letter that is easy on a US layout may need AltGr elsewhere.
Elements that are not rendered (hidden, display: none) get no access key.
One key, one element. Browsers handle two elements with the same key differently (Firefox cycles focus between them). Do not rely on either behaviour.
Related
data-hotkey — VB's shortcut binding, display and aria-keyshortcuts.
accesskey — a quick shortcut in an internal tool where the users know their browser's modifier, and no script is wanted.
data-hotkey — anything public-facing: you choose the full combination, it works the same in every browser, it is listed in <short-cuts>, and single-key shortcuts respect the user's preference.
aria-keyshortcuts — only describes a shortcut that script already handles. It does not create one.