KeyboardEvent: altKey Eigenschaft
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.
Die schreibgeschützte Eigenschaft KeyboardEvent.altKey
ist ein boolescher Wert, der angibt, ob die alt-Taste (Option oder ⌥ auf macOS) beim Auftreten des Ereignisses gedrückt wurde (true
) oder nicht (false
).
Wert
Ein boolescher Wert.
Beispiele
html
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>altKey example</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>
Press any character key, with or without holding down the ALT key.<br />
You can also use the SHIFT key together with the ALT key.
</p>
</body>
</html>
Spezifikationen
Specification |
---|
UI Events # dom-keyboardevent-altkey |
Browser-Kompatibilität
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.