event.shiftKey

概述

表明当事件触发时,SHIFT键是否处于按下状态.

语法

var bool = event.shiftKey;

bool 的值为 truefalse

例子

<html>
<head>
<title>shiftKey example</title>

<script type="text/javascript">

function showChar(e){
  alert(
    "Key Pressed: " + String.fromCharCode(e.charCode) + "\n"
    + "charCode: " + e.charCode + "\n"
    + "SHIFT key pressed: " + e.shiftKey + "\n"
    + "ALT key pressed: " + e.altKey + "\n"
  );
}

</script>
</head>

<body onkeypress="showChar(event);">
<p>按下一个字符键,尝试同时按下SHIFT键.<br />
你也可以同时按下SHIFT键和ALT键.</p>
</body>
</html>

规范

shiftKey

文档标签和贡献者

最后编辑者: khalid32,