MouseEvent metaKey Property

Definition and Usage

The metaKey property returns a boolean value indicating whether the "META" key was pressed when the mouse event was triggered.

Not all keyboards have a meta key. For Sun Microsystems keyboards and MIT and LISP machine keyboards, it is common. The meta key is marked as "META" or marked with a solid diamond symbol "◆".

On Mac keyboards, the META key is represented by the "Command/Cmd" ("⌘") key.

Note:This property is read-only.

Example

Determine whether the "META" key was pressed when the mouse button was clicked:

if (event.metaKey) {
  alert("The META key was pressed!");
}
  alert("The META key was NOT pressed!");
}

Try It Yourself

Syntax

event.metaKey

Technical Details

Return value:

A boolean value indicating whether the "META" key was pressed when the mouse event occurred.

Possible values:

  • true - The meta key was pressed
  • false - The meta key was not pressed
DOM Version: DOM Level 2 Events

Browser Support

Properties Chrome IE Firefox Safari Opera
metaKey Support Support Support Support Support

Related Pages

HTML DOM Reference Manual:MouseEvent altKey Property

HTML DOM Reference Manual:MouseEvent ctrlKey Property

HTML DOM Reference Manual:MouseEvent shiftKey Property