HTMLElement: accessKeyLabel property
The HTMLElement.accessKeyLabel
read-only property returns a string containing the element's
browser-assigned access key (if any); otherwise it returns an empty string.
Example
JavaScript
js
const btn = document.getElementById("btn1");
const shortcutLabel = btn.accessKeyLabel || btn.accessKey;
btn.title += ` [${shortcutLabel.toUpperCase()}]`;
btn.onclick = () => {
const feedback = document.createElement("output");
feedback.textContent = "Pressed!";
btn.insertAdjacentElement("afterend", feedback);
};
HTML
html
<button accesskey="h" title="Caption" id="btn1">Hover me</button>
Result
Specifications
Specification |
---|
HTML # dom-accesskeylabel |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
accessKeyLabel |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
HTMLElement.accessKey
- The accesskey global attribute.