This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

shiftLeft

Property of dom/KeyboardEventdom/KeyboardEvent

Syntax

var result = element.shiftLeft;
element.shiftLeft = value;

Examples

The following example shows how to use the shiftLeft property to indicate when the user presses the left or right SHIFT keys.

<HEAD>
<SCRIPT>
function init() {
    spanLeftShift.innerText='false';
    spanRightShift.innerText='false';
}

function indicate(obj, arg) {
    obj.innerText=arg;
}

function ShiftDown() {
    if (event.shiftLeft) {
        indicate(spanLeftShift,'true');
    }
    else {
        if (event.shiftKey) {
        indicate(spanRightShift,'true');
        }
    }
}

function ShiftUp() {
    if (!event.shiftKey) {
        indicate(spanLeftShift,'false');
        indicate(spanRightShift,'false');
    }
}
</SCRIPT>
</HEAD>

<BODY onload="document.body.focus(); init()" onkeydown="ShiftDown();" onkeyup="ShiftUp();">

<P>Press either the left or right SHIFT key.</P>
<TABLE>
<TR>
<TD><I>Left SHIFT Key Pressed</I></TD>
<TD><I>Right SHIFT Key Pressed</I></TD>
</TR>
<TR>
<TD ALIGN="center"><SPAN ID="spanLeftShift"></SPAN></TD>
<TD ALIGN="center"><SPAN ID="spanRightShift"></SPAN></TD>
</TR>
</TABLE>
</P>
</BODY>

View live example

Notes

Remarks

The Document must have focus for this property to return true.

Syntax

Attributions