EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

ctrlLeft property

Sets or retrieves the state of the left CTRL key.

Syntax

JavaScript

p = object.ctrlLeft

Property values

Type: Boolean

false (false)

Left CTRL key is not pressed.

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>
</body>

See also

event
ctrlKey

 

 

표시:
© 2014 Microsoft