{"id":24144609,"url":"https://github.com/tillsanders/access-key-label-polyfill","last_synced_at":"2026-01-23T09:18:10.457Z","repository":{"id":57172374,"uuid":"328147533","full_name":"tillsanders/access-key-label-polyfill","owner":"tillsanders","description":"Polyfills the accessKeyLabel property to improve discoverability of native keyboard shortcuts for your website. Tiny and dependency-free.","archived":false,"fork":false,"pushed_at":"2024-10-17T13:18:45.000Z","size":175,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-20T21:42:27.032Z","etag":null,"topics":["a11y","accesskeylabel","browser","polyfill"],"latest_commit_sha":null,"homepage":"https://tillsanders.github.io/access-key-label-polyfill/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tillsanders.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-09T12:14:21.000Z","updated_at":"2024-10-17T13:23:10.000Z","dependencies_parsed_at":"2024-10-20T13:06:54.551Z","dependency_job_id":null,"html_url":"https://github.com/tillsanders/access-key-label-polyfill","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"4ae7077022cb83f2d3f09b9a12d1d15136e156de"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tillsanders%2Faccess-key-label-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tillsanders%2Faccess-key-label-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tillsanders%2Faccess-key-label-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tillsanders%2Faccess-key-label-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tillsanders","download_url":"https://codeload.github.com/tillsanders/access-key-label-polyfill/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233570543,"owners_count":18695866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a11y","accesskeylabel","browser","polyfill"],"created_at":"2025-01-12T06:12:20.339Z","updated_at":"2026-01-23T09:18:10.450Z","avatar_url":"https://github.com/tillsanders.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AccessKeyLabelPolyfill\n\nPolyfills the accessKeyLabel property to improve discoverability of native keyboard shortcuts for\nyour website. Tiny (\u003c 1KB) and dependency-free.\n\n[![Version npm](https://img.shields.io/npm/v/access-key-label-polyfill.svg)](https://www.npmjs.com/package/access-key-label-polyfill)\n[![Tests](https://img.shields.io/github/actions/workflow/status/tillsanders/access-key-label-polyfill/test.yml?branch=main\u0026label=Tests)](https://github.com/tillsanders/access-key-label-polyfill/actions?query=workflow%3Atest+branch%3Amain)\n[![JSR](https://jsr.io/badges/@tillsanders/access-key-label-polyfill)](https://jsr.io/@tillsanders/access-key-label-polyfill)\n[![JSR Score](https://jsr.io/badges/@tillsanders/access-key-label-polyfill/score)](https://jsr.io/@tillsanders/access-key-label-polyfill)\n\n## Background\n\nWith the [`accesskey` HTML property](https://developer.mozilla.org/de/docs/Web/HTML/Globale_Attribute/accesskey),\nyou can easily provide keyboard shortcuts for the buttons of your web application.\n\n```html\n\u003cbutton accesskey=\"D\"\u003eDo crazy stuff\u003c/button\u003e\n\u003c!-- Can be activated using Ctrl + Alt + D --\u003e\n```\n\nSadly, most users don't even know these shortcuts can be used, even if the web developer provided\nthem. To make these shortcuts more discoverable you might decide to use the `title` property, a\ntooltip or some other UI element to display the keyboard shortcut.\n\n```html\n\u003cbutton accesskey=\"D\"\u003eDo crazy stuff\u003c/button\u003e\n\u003csmall\u003eHint: Use Ctrl + Alt + D to quickly access this button!\u003c/small\u003e\n```\n\nA good idea, but browsers use different combinations of modifier keys. But thanks to the\n[`accessKeyLabel` property](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/accessKeyLabel),\nwe can easily get a string representation of the keyboard shortcut assigned by the browser. Sooo,\nwe're good, right? Alas, not quite. Though the API has been around for years,\n[browser support](https://caniuse.com/?search=accessKeyLabel) isn't good enough. Especially, since\nChrome is still missing out. To help bridge the gap, you can use this polyfill and finally let your\nusers benefit from the keyboard shortcuts you provide!\n\n[**Demo**](https://tillsanders.github.io/access-key-label-polyfill/)\n\n[**Full length article** about accessKey and accessKeyLabel on dev.to](https://dev.to/tillsanders/boy-was-it-hard-to-implement-proper-keyboard-shortcuts-4d72)\n\n## Usage\n\n### NPM\n\nSimply install the polyfill:\n\n```sh\nnpm i access-key-label-polyfill\n# or\nyarn add access-key-label-polyfill\n```\n\nAnd the import and run the install function:\n\n```javascript\nimport \"access-key-label-polyfill\";\n```\n\nNote: Starting with v1.0.0, this polyfill is a native ES module.\n\n### Browser\n\nYou can also use this polyfill 'oldschool'. Simply download the package files and add a script tag\nto your body:\n\n```html\n\u003cbody\u003e\n  \u003c!-- ... --\u003e\n  \u003cscript type=\"module\" src=\"path/to/AccessKeyLabelPolyfill.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n```\n\n## Demo\n\nYou can view the demo here: \u003chttps://tillsanders.github.io/access-key-label-polyfill/\u003e\n\nThe demo will tell you wether the polyfill detected native support for `accessKeyLabel` or not and\nwill display either output below the button.\n\n## How does it work?\n\nFirst, the polyfill will try to detect wether the browser already supports `accessKeyLabel`. If it\ndoes, it will exit immediately. If the browser doesn't support this API, the polyfill will add a\nsmall function to fill the gap. This function will try to detect the browser / operating system and\nreturn the correct label. You can then use `accessKeyLabel` as expected.\n\n### Caveats\n\n- To return the correct label, the polyfill needs to determine the correct operating system, browser\n  and sometimes even the browser version. This is done with a very lightweight script and based on\n  the user-agent. While this has been tested successfully and should work reliably, wrong\n  user-agents can still mess it up, of course.\n- The polyfill currently supports the major browsers on macOS (including Firefox \u003c v14), namely\n  Chrome. As well as Internet Explorer, Edge and Safari on iOS / iPadOS. There might be more\n  browsers, that need this polyfill, but there is surprisingly little information regarding support,\n  so please feel free to open an issue if you come across an unsupported case.\n- Chrome on Android does not seem to support `accessKey`, or at least, I was unable to guess (why\n  is this not documented anywhere?!) the correct modifier keys. Would love to get help with this!\n\n# Changelog\n\n## 1.0.2 - (26.09.2025)\n\n- Fix GitHub Actions workflow for publishing\n\n## 1.0.1 – (26.09.2025)\n\n- Update (development) dependencies\n- Use OIDC for trusted publishing to NPM\n- Set up JSR\n\n## 1.0.0 – (17.10.2024)\n\n- BREAKING: Convert to native ESM module (remove UMD support)\n- BREAKING: Remove installation function (`accessKeyLabelPolyfill()`) and install automatically instead\n- Add support for Chrome on Windows\n- Update dependencies and overhaul tooling\n- Improve CI/CD\n- Move to Vite + Vitest\n- Update demo and documentation\n\n## 0.1.1 – (10.01.2021)\n\n- Fix browser detection of Edge\n\n## 0.1.0 – (09.01.2021)\n\n- Initial implementation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftillsanders%2Faccess-key-label-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftillsanders%2Faccess-key-label-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftillsanders%2Faccess-key-label-polyfill/lists"}