ctrlLeft property (Internet Explorer)

Switch View :
ScriptFree
ctrlLeft property

Sets or retrieves the state of the left CTRL key.

Syntax

JavaScript

p = object.ctrlLeft

Property values

Type: Boolean

VARIANT_FALSE (false)

Left CTRL key is not pressed.

VARIANT_TRUE (true)

Left CTRL key is pressed.

Remarks

This property is currently supported only in Microsoft Windows NT 4.0 and Windows 2000.

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

Examples

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

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


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

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

function CtrlDown() {
    if (event.ctrlLeft) {
        indicate(spanLeftCtrl,'true');
    }
    else {
        if (event.ctrlKey) {
            indicate(spanRightCtrl,'true');
        }
    }
}

function CtrlUp() {
    if (!event.ctrlKey) {
        indicate(spanLeftCtrl,'false');
        indicate(spanRightCtrl,'false');
    }
}
</SCRIPT>
</HEAD>

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

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

See also

event
ctrlKey

 

 

Send comments about this topic to Microsoft

Build date: 3/14/2012

Community Content

Mr. Raymond Kenneth Petry
update?
Appears to work in Windows XP IE8 or IE7/8, (However, like ctrlKey, setting it, breaks its handler).