This article example describes the method of JS to determine whether the Shift key has been pressed. Share it for your reference. The specific implementation method is as follows:
Copy the code as follows: <html>
<head>
<title>Use js to determine whether the Shift key has been pressed</title>
<script type="text/javascript">
function isKeyPressed(event)
{
if (event.shiftKey==1)
{
alert("shift was pressed")
}
else
{
alert("shift not pressed")
}
}
</script>
</head>
<body onmousedown="isKeyPressed(event)">
<p>Click a location in the document. The message box will tell you whether the shift key has been pressed. </p>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.