, , , , , , , , and
Event Onkeydown
# onkeydown Event
[ Event Object](#)
## Example
Execute JavaScript code when a user presses a key:
[Try it Β»](#)
* * *
## Definition and Usage
The onkeydown event occurs when a user presses a keyboard key.
**Tip:** The event trigger order associated with the onkeydown event:
1. onkeydown
2. onkeypress
3. onkeyup
## Syntax
In HTML:
In JavaScript:
_object_.onkeydown=function(){_SomeJavaScriptCode_};
| Parameter | Description |
| :--- | :--- |
| _SomeJavaScriptCode_ | Required. Specifies the JavaScript to be executed when the event occurs. |
* * *
## Browser Support

The onkeydown event is supported by all major browsers.
* * *
## HTML Tags That Support This Event:
The onkeydown attribute can be used with all HTML elements, except: , ,
, , , , , , , , and.
* * Event Object](#)
, , , , , , , , and
YouTip