Home Web Front-end HTML Tutorial The event attribute onkeypress that is triggered when the user presses a key (on the keyboard) in html

The event attribute onkeypress that is triggered when the user presses a key (on the keyboard) in html

Nov 06, 2017 am 09:35 AM
html button trigger

Example

Execute a piece of JavaScript when the user presses a key:

<input type="text" onkeypress="displayResult()">
Copy after login

Browser support

IE

Firefox

Chrome

Safari

Opera

All major browsers support the onkeypress attribute.

Definition and Usage

The onkeypress property is triggered when the user presses a key (on the keyboard).

Tip: The order of events relative to the onkeypress event:

onkeydown onkeypress onkeyup

Note: In any browser, the onkeypress event will not be triggered by all key presses (such as ALT , CTRL, SHIFT, ESC).

Note: The onkeypress attribute is not applicable to the following elements: , ,
, , ,