shiftKeyEvent Property
Event Object
Definition and Usage
The shiftKey event property returns a boolean value indicating whether the "SHIFT" key was pressed and held when the event occurred.
Syntax
event.shiftKey=true|false|1|0
Examples
Examples
The following example can prompt whether the "SHIFT" key is held down when the mouse button is clicked:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial(example.com)</title>
<script>
function isKeyPressed(event){
if (event.shiftKey==1){
alert("Shift key pressed!");
}
else{
alert("Shift key not pressed!");
}
}
</script>
</head>
<body onmousedown="isKeyPressed(event)">
<p>Click this paragraph, and a popup will prompt whether the Shift key is pressed.</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial(example.com)</title>
<script>
function isKeyPressed(event){
if (event.shiftKey==1){
alert("Shift key pressed!");
}
else{
alert("Shift key not pressed!");
}
}
</script>
</head>
<body onmousedown="isKeyPressed(event)">
<p>Click this paragraph, and a popup will prompt whether the Shift key is pressed.</p>
</body>
</html>
Try it Yourself »
Event Object Other Extensions