This topic has not yet been rated - Rate this topic

shiftLeft property

Retrieves the state of the left SHIFT key.

Syntax

JavaScript

p = object.shiftLeft

Property values

Type: Boolean

VARIANT_FALSE (false)

Left SHIFT key is not pressed.

VARIANT_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.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/starLeft.htm


<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

 

 

Send comments about this topic to Microsoft

Build date: 3/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ