在 JavaScript 中,altKey 滑鼠事件的作用是什麼?
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>
廣告