KeyboardEvent: altKey プロパティ
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.altKey
は読み取り専用のプロパティで、イベント発生時に alt キー(macOS では Option または ⌥)が押されたか (true
) または押されていないか (false
) を示す論理値です。
値
論理値です。
例
html
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>altKey の例</title>
<script>
function showChar(e) {
alert(
"Key KeyDown: " +
String.fromCharCode(e.charCode) +
"\n" +
"charCode: " +
e.charCode +
"\n" +
"ALT key KeyDown: " +
e.altKey +
"\n",
);
}
</script>
</head>
<body onkeydown="showChar(event);">
<p>
ALT キーを押したまま、または押さずに、任意の文字キーを押してください。<br />
また、 SHIFT キーと ALT キーを同時に使用することもできます。
</p>
</body>
</html>
仕様書
Specification |
---|
UI Events # dom-keyboardevent-altkey |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
altKey |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.