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.


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:
CTRL key is up.
CTRL key is down.
Default: this property has no default value.

Example HTML code 1:

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

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content