--- title: event.shiftKey slug: Web/API/event.shiftKey translation_of: Web/API/MouseEvent/shiftKey translation_of_original: Web/API/event.shiftKey ---
{{ ApiRef() }}
表明当事件触发时,SHIFT键是否处于按下状态.
var bool = event.shiftKey;
bool 的值为 true 或 false
<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>
{{ languages( { "pl": "pl/DOM/event.shiftKey" ,"en": "en/DOM/event.shiftKey" } ) }}