HTMLElement: accessKeyLabel property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{ APIRef("HTML DOM") }}
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
HTML
html
<button accesskey="h" title="Caption" id="btn1">Hover me</button>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);
};Result
{{ EmbedLiveSample('Example') }}
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{domxref("HTMLElement.accessKey")}}
- The accesskey global
attribute.