Der Konstruktor KeyboardEvent.altKey
hat die Eigenschaft Boolean
und zeigt an ob alt Taste (Option oder ⌥ in OS X) gedrückt wurde (true
) oder (false
) nicht gerdrückt wurde, wenn das Ereignis eintritt.
Syntax
var altKeyPressed = instanceOfKeyboardEvent.altKey
Examples
<html>
<head>
<title>altKey example</title>
<script type="text/javascript">
function showChar(e){
alert(
"Key Pressed: " + String.fromCharCode(e.charCode) + "\n"
+ "charCode: " + e.charCode + "\n"
+ "ALT key pressed: " + e.altKey + "\n"
);
}
</script>
</head>
<body onkeypress="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>
Specifications
Specification | Status | Comment |
---|---|---|
Document Object Model (DOM) Level 3 Events Specification Die Definition von 'KeyboardEvent.altkey' in dieser Spezifikation. |
Veraltet | Initial definition. |
Browser compatibility
Wir konvertieren die Kompatibilitätsdaten in ein maschinenlesbares JSON Format.
Diese Kompatibilitätstabelle liegt noch im alten Format vor,
denn die darin enthaltenen Daten wurden noch nicht konvertiert.
Finde heraus wie du helfen kannst!
Feature | Edge | Firefox (Gecko) | Chrome | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | (Ja) | (Ja) | (Ja) | (Ja) | (Ja) | (Ja) |
Feature | Edge | Firefox Mobile (Gecko) | Android | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Ja) | ? | ? | ? | ? | ? |