Home  >  Article  >  Web Front-end  >  Execute a script when the user releases a key in HTML?

Execute a script when the user releases a key in HTML?

王林
王林forward
2023-09-07 15:01:02907browse

Execute a script when the user releases a key in HTML?

Use the onkeyup attribute. The onkeyup attribute fires when the user releases the key.

Example

You can try running the following code to execute the script when the key is released -

<!DOCTYPE html>
<html>
   <body>
      <p>Press a key inside the textbox.</p>

      <input type = "text" onkeydown = "display()">

      <script>
         function display() {
            alert("You released a key!");
         }
      </script>
   </body>
</html>

The above is the detailed content of Execute a script when the user releases a key in HTML?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete