HTMLElement.accessKeyLabel

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.

Syntax

label = element.accessKeyLabel

Example

JavaScript

var btn = document.getElementById('btn1');
var shortcutLabel = btn.accessKeyLabel || btn.accessKey;
btn.title += ' [' + shortcutLabel.toUpperCase() + ']';

btn.onclick = function () {
  var feedback = document.createElement('output');
  feedback.textContent = 'Pressed!';
  btn.insertAdjacentElement('afterend', feedback);
};

HTML

<button accesskey="h" title="Caption" id="btn1">Hover me</button>

Result

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
accessKeyLabel
No
No
8
No
No
14
No
No
8
No
14
No

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/accessKeyLabel