shiftLeft property

Retrieves the state of the left SHIFT key.

Syntax

JavaScript

p = object.shiftLeft

Property values

Type: Boolean

false (false)

Left SHIFT key is not pressed.

true (true)

Left SHIFT key is pressed.

Remarks

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

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>

See also

event
shiftKey

 

 

Build date: 11/14/2012

Show:
© 2014 Microsoft