KeyboardEvent metaKey Property

Example

Was the META key pressed when the event occurred?

if (event.metaKey) {
  text = "The META key was pressed!";
} else {
  text = "The META key was NOT pressed!";
}
Try it Yourself »

Description

The metaKey property returns true if the META key is pressed when a mouse event is triggered, otherwise it returns false.

The metaKey property is read-only.

Note

Not all keyboards have a META key.

On Windows the META key is the Window (⊞) key.

On Mac machines the META key is the Cmd (⌘) key.

See Also:

The key Property

The altKey Property

The ctrlKey Property

The shiftKey Property

The location Property

The Keyboard Event Object


Syntax

event.metaKey

Technical Details

Return Value: A Boolean.
true if the META key was pressed when a mouse event occured, otherwise false.
DOM Version: DOM Level 2 Keyboard Events.

Browser Support

event.metaKey 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.