Execute a JavaScript when a user is pressing a key:
![]()
The onkeydown event attribute is supported in all major browsers.
The onkeydown attribute fires when the user is pressing a key (on the keyboard).
Tip: The order of events related to the onkeydown event:
Note: The onkeydown attribute CANNOT be used with: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, or <title>.
None.
| Value | Description |
|---|---|
| script | The script to be run on onkeydown |
HTML Event Attributes
Your message has been sent to W3Schools.