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

altLeft property (event)

Browser support:
Sets or retrieves a Boolean value that indicates whether the left ALT key was down at the time when the event occurred.
If it is not necessary to know which ALT key was pressed, use the cross-browser altKey property.
For CTRL and SHIFT keys, use the (ctrlKey, ctrlLeft) and (shiftKey, shiftLeft) properties.
Note that Internet Explorer from version 9 started to support different event objects similarly to Firefox, Opera, Google Chrome and Safari. The event object passed to an event handler and the event object referred to by the window.event property are different in Internet Explorer from version 9 (except if the event handler is registered with the attachEvent method). The altLeft property is only supported by the window.event object.

Syntax:

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

Possible values:

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

Example HTML code 1:

This example illustrates the use of the altLeft property:
<head>
    <script type="text/javascript">
        function GetAltState (event) {
            if (event.altKey) {
                    // window.event and event differ in IE9 !!!
                if (window.event && 'altLeft' in window.event) {
                    if (window.event.altLeft) {
                        alert ("Left ALT key is down.");
                    }
                    else {
                        alert ("Right ALT key is down.");
                    }
                }
                else {
                    alert ("ALT key is down.");
                }
            }
            else {
                alert ("ALT key is up.");
            }
        }
    </script>
</head>
<body>
    Press and hold down the left or right ALT key before you click on the button.
    <br />
    <button onclick="GetAltState (event);">Get ALT 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