什麼是 JavaScript 中的 onkeydown 事件?


當按下鍵時觸發 onkeydown 事件。你可以嘗試執行以下程式碼來學習如何在 JavaScript 中使用onkeydown事件 -

示例

<html>
   <head>
      <script>
         <!--
            function sayHello() {
               alert("A key is pressed.")
            }
         //-->
      </script>
   </head>
   <body>
      <input type = "text" onkeydown = "sayHello()">
   </body>
</html>

更新於: 19-Jun-2020

306 次瀏覽

開啟你的 職業生涯

完成課程認證

開始學習
廣告
© . All rights reserved.