KeyboardEvent altKey Property
Definition and Usage
The altKey property returns a boolean value indicating whether the "ALT" key was pressed during a keyboard or mouse event.
Note:On some Mac keyboards, the "ALT" key is displayed as "Option" or "Opt".
Note:This property is read-only.
Example
Determine if the "ALT" key is pressed when a keyboard key is clicked:
var x = document.getElementById("demo"); if (event.altKey) { x.innerHTML = "The ALT key was pressed!"; } x.innerHTML = "The ALT key was NOT pressed!"; }
Syntax
event.altKey
Technical Details
Return value: |
A boolean value indicating whether the "ALT" key was pressed during the keyboard event. Possible values:
|
---|---|
DOM Version: | DOM Level 2 Events |
Browser Support
Properties | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
altKey | Support | Support | Support | Support | Support |
Related Pages
HTML DOM Reference Manual:KeyboardEvent ctrlKey Property
HTML DOM Reference Manual:KeyboardEvent metaKey Property
HTML DOM Reference Manual:KeyboardEvent shiftKey Property