KeyboardEvent altKey Property
Example
Was the ALT key pressed when the event occurred?
if (event.altKey) {
text = "The ALT key was pressed!";
} else {
text = "The ALT key was NOT pressed!";
}
Try it Yourself »
Description
The altKey
property returns true
if
the ALT key is pressed when a keyboard event occurs.
Otherwise it returns false
.
The altKey
property is read-only.
See Also:
Syntax
event.altKey
Technical Details
Return Value: |
A Boolean. Returns true if the ALT key is pressed when a keyboard event occurs.Otherwise it returns false .
|
---|---|
DOM Version: | DOM Level 2 Keyboard Events. |
Browser Support
event.altkey
is a DOM Level 2 (2001) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |