altKey 滑鼠事件在 JavaScript 中的作用是什麼?
altkey 滑鼠事件屬性用於在滑鼠按鈕被單擊時顯示 SHIFT 鍵是否被按下。
示例
你可以嘗試執行以下程式碼來學習如何在 JavaScript 中實現altKey 滑鼠事件。
<!DOCTYPE html> <html> <body onmousedown="funcAltKey(event)"> <div>Press and hold ALT key and then click here.</div> <script> function funcAltKey(event) { if (event.altKey) { alert("ALT key: Pressed"); } else { alert("ALT key: NOT Pressed"); } } </script> </body> </html>
廣告