Execute a JavaScript when a user is pressing a key:
The onkeydown event occurs when the user is pressing a key (on the keyboard).
Tip: The order of events related to the onkeydown event:
In HTML:
In JavaScript:
| Parameter | Description |
|---|---|
| SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs |
![]()
The onkeydown event is supported in all major browsers.
The onkeydown attribute can be used within ALL HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>.
Event Object
Your message has been sent to W3Schools.