, , , , , , , , and
Event Onkeypress
# onkeypress Event
[ Event Object](#)
## Example
Execute JavaScript code when the user presses a keyboard button:
[Try it Β»](#)
* * *
## Definition and Usage
The onkeypress event occurs when a keyboard key is pressed down and released.
**Tip:** The event execution order associated with the onkeypress event is:
1. onkeydown
2. onkeypress
3. onkeyup
**Note:** The onkeypress event only listens for letters and numbers in all browsers; it cannot listen for some special keys (ALT, CTRL, SHIFT, ESC, arrows, etc.). To listen for whether a user presses a key, use the (#) event. The onkeydown event is supported by all browsers.
## Syntax
In HTML:
In JavaScript:
_object_.onkeypress=function(){_SomeJavaScriptCode_};
| Parameter | Description |
| :--- | :--- |
| _SomeJavaScriptCode_ | Required. Specifies the JavaScript to be executed when the event occurs. |
* * *
## Browser Support

The onkeypress event is supported by all major browsers.
* * *
## HTML Tags That Support the onkeypress Event:
The onkeypress attribute can be applied to all HTML elements, except: , ,
, , , , , , , , and.
* * Event Object](#)
, , , , , , , , and
YouTip