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 if the "META" key was pressed when the mouse button was clicked:

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

Try it yourself

Syntax

event.metaKey

Technical details

Return value:

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

Possible values:

  • true - meta key pressed
  • false - meta key not pressed
DOM Version: Matukio ya DOM Level 2

Matumizi ya kivumila

Mimba Chrome IE Firefox Safari Opera
metaKey Mwongozo Mwongozo Mwongozo Mwongozo Mwongozo

Vipindi vya vitengo

Mafunzo ya HTML DOM:Kipimo cha altKey kwa MouseEvent

Mafunzo ya HTML DOM:Kipimo cha ctrlKey kwa MouseEvent

Mafunzo ya HTML DOM:Kipimo cha shiftKey kwa MouseEvent