function isKeyPressed(event) { if (event.shiftKey==1) { alert("The shift key was pressed!") } else { alert("The shift key was NOT pressed!") } }
<body onmousedown="isKeyPressed(event)"> <p>在文档中点击某个位置。消息框会告诉你是否按下了 shift 键。</p> </body>