MouseEvent ctrlKey attribute

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

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:

A 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: DOM Level 2 Events

Browser Support

Properties Chrome IE Firefox Safari Opera
ctrlKey Support Support Support Support Support

Related Pages

HTML DOM Reference Manual:MouseEvent altKey Property

HTML DOM Reference Manual:MouseEvent metaKey Property

HTML DOM Reference Manual:MouseEvent shiftKey Property