HTMLElement: accessKeyLabel プロパティ

HTMLElement.accessKeyLabel は読み取り専用プロパティで、要素に割り当てられたアクセスキーを(あれば)文字列で返します。それ以外の場合は空文字列を返します。

構文

js
label = element.accessKeyLabel

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="キャプション" id="btn1">
  マウスを当ててください
</button>

結果

仕様書

Specification
HTML
# dom-accesskeylabel

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
accessKeyLabel

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

関連情報