MouseEvent ctrlKey property

Definition and usage

The ctrlKey property returns a boolean value indicating whether the 'CTRL' key was pressed when the mouse event was triggered.

Note:This property is read-only.

Example

Determine if the 'CTRL' key was pressed when clicking the mouse button:

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

Try it yourself

Syntax

event.ctrlKey

Technical details

Return value:

Boolean value indicating whether the 'CTRL' key was pressed when the mouse event occurred.

Possible values:

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

Muungano wa kawaida wa kifungu

Mwendo Chrome IE Firefox Safari Opera
ctrlKey Msaada Msaada Msaada Msaada Msaada

Vipengele vya kuelewa

Mwongozo wa HTML DOM:属性 altKey ya MouseEvent

Mwongozo wa HTML DOM:属性 metaKey ya MouseEvent

Mwongozo wa HTML DOM:属性 shiftKey ya MouseEvent