You are here: Reference > JavaScript > client-side > event handling > properties > ctrlKey (event)

ctrlKey property (event)

Browser support:
Sets or retrieves whether the left or right CTRL key was down at the time when the event occurred.
In Internet Explorer, use the ctrlLeft property to detect whether the left or right CTRL key is down.
For ALT and SHIFT keys, use the altKey and shiftKey properties.

Syntax:

object.ctrlKey;
You can find the related objects in the Supported by objects section below.
The ctrlKey property is read-only, except if the event object is created with the createEventObject method when it is read/write.

Possible values:

Boolean, one of the following values:
false
CTRL key is up.
true
CTRL key is down.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the ctrlKey property:
<head>
    <script type="text/javascript">
        function GetCtrlState (event) {
            if (event.ctrlKey) {
                alert ("Ctrl key is down.");
            }
            else {
                alert ("Ctrl key is up.");
            }
        }
    </script>
</head>
<body>
    Press and hold down the CTRL key before you click on the button.
    <br />
    <button onclick="GetCtrlState (event);">Get Ctrl key state!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content