HTML onkeypress Attribute
Example
<input type="text" onkeypress="myFunction()">
Meaning
The onkeypress attribute specifies the script run when a user presses a key.
Related Keyboard Events
Standard Syntax
<element onkeypress="script">
Applies to:
The onkeypress attribute can be used on the following element:
| Element | Attribute |
|---|---|
| All HTML elements. | onkeypress |
Advertisement
Attribute Values
| Value | Description |
|---|---|
| script | Specifies the script to be run on onkeypress |