KeyboardEvent: metaKey プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
KeyboardEvent.metaKey
は読み取り専用のプロパティで、 プロパティは、イベントが発生したときに Meta キーが押されていたか (true
) あるいは押されていなかった (false
) かを示す論理値を返します。オペレーティングシステムによっては、キーが検出されないように遮蔽されることがあります。
メモ: Macintosh のキーボードでは、これは ⌘ Command キーです。
警告:
少なくとも Firefox 48 の時点で、 ⊞ Windows キーは "Meta" キーとみなされなくなりました。⊞ Windows キーが押されたとき KeyboardEvent.metaKey
は false
になります。
値
論理値です。
例
html
<button onclick="ismetaKey(event)">Click me with the meta key</button>
<p id="output"></p>
js
function ismetaKey(e) {
document.querySelector("#output").textContent =
`metaKey pressed? ${e.metaKey}`;
}
結果
仕様書
Specification |
---|
UI Events # dom-keyboardevent-metakey |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
metaKey |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full 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.