Browse By Name
HTMLCSSJavaScriptAppendix
You are here: Reference > JavaScript > client-side > event handling > properties > shiftLeft (event)

shiftLeft property (event)

A A Font size Print Content Add new content Share Share
Browser support:
Sets or retrieves a Boolean value that indicates whether the left SHIFT key was down at the time when the event occurred.
If it is not necessary to know which SHIFT key was pressed, use the cross-browser shiftKey property.
For ALT and CTRL keys, use the (altKey, altLeft) and (ctrlKey, ctrlLeft) properties.

Syntax:

object.shiftLeft;
You can find the related objects in the Supported by objects section below.
The shiftLeft property is read-only for the window.event object, but it is read/write for event objects created by the createEventObject method.

Possible values:

Boolean that sets or retrieves the state of the left SHIFT key.
One of the following values:
false
Left SHIFT key is up.
true
Left SHIFT key is down.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the shiftLeft property:
<head>
    <script>
        function GetShiftState (event) {
            if (event.shiftKey) {
                if (event.shiftLeft != undefined) {
                    if (event.shiftLeft) {
                        alert ("Left Shift key is down.");
                    }
                    else {
                        alert ("Right Shift key is down.");
                    }
                }
                else {
                    alert ("Shift key is down.");
                }
            }
            else {
                alert ("Shift key is up.");
            }
        }
    </script>
</head>
<body>
    Press or release the left or right SHIFT key before you click on the button.
    <br />
    <button onclick="GetShiftState (event);">Get Shift keys 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