![]() |
Definition and UsageThe onkeydown attribute fires when the user is pressing a key (on the keyboard). Tip: The order of events related to the onkeydown event:
Applies toThe onkeydown attribute is part of the Event Attributes, and can be used on any HTML elements.
Browser Support |
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>A function is triggered when the user is pressing a key in the input field.</p>
<input type="text" onkeydown="myFunction()">
<script>
function myFunction() {
alert("You pressed a key inside the input field");
}
</script>
</body>
</html>
html onkeydown attribute |
How to Execute a JavaScript when a user is pressing a key - HTML onkeydown | HTML Attribute |
Read Full: | HTML Attribute |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Attribute |
Uploaded by: | Admin |
Views: | 163 |
Reffered: https://www.w3schools.com/tags/att_onkeydown.asp