MouseEvent altKey Property

Example

Was the "ALT" key pressed when the mouse button was clicked:

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 mouse event occurs.

Otherwise it returns false.

The altKey property is read-only.

Note

On some keyboards, the ALT key is displayed as Option or Opt.

See Also:

The ctrlKey Property

The metaKey Property

The shiftKey Property

The Mouse Event Object


Syntax

event.altKey

Technical Details

Return Value: A Boolean.
Returns true if the ALT key is pressed when a mouse event occurs.
Otherwise it returns false.
DOM Version: DOM Level 2 Mouse 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


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.