Retrieves the state of the SHIFT key.
dhtml语法
[ bKey = ] event.shiftKey
DHTML可能的值
bKey | Boolean that
receives one of the following values.false | SHIFT key is not pressed. | true | SHIFT key is pressed. |
|
The property is read-only.
The property has no default value.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see about dynamic properties.
DHTML代码范例
This example demonstrates how to retrieve the state of the SHIFT key. Any key pressed fires the onkeydown event handler, enabling you to retrieve the state of the shift key. because the onkeyup event handler only fires when a key is released, it always returns false for the shift key's state. the onkeypress event handler only fires when the user presses an alphanumeric keyit will not fire if the shift key is pressed.
<HTML>
.
.
.
<BODY onkeydown="okd.innerText=event.shiftKey;"
onkeypress="okp.innerText=event.shiftKey;"
onkeyup="oku.innerText=event.shiftKey;">
State of SHIFT key from the onkeydown event handler:
<SPAN id="okd" class="b"></SPAN><BR>
State of SHIFT key from the onkeyup event handler:
<SPAN id="oku" class="b"></SPAN><BR>
State of SHIFT key from the onkeypress event handler:
<SPAN id="okp" class="b"></SPAN>
.
.
.
</BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.
是否符合公共标准
There is no public standard that applies to this property.
Applies To
更多语法参考
shiftLeft