Home > Web Front-end > HTML Tutorial > html event attribute onkeydown triggered when the user presses a key

html event attribute onkeydown triggered when the user presses a key

黄舟
Release: 2017-11-06 09:32:48
Original
2858 people have browsed it

Example

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

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

Browser support


IE

Firefox

Chrome

Safari

Opera


All major browsers support onkeydown Attributes.

Definition and Usage

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

Tips: Event order relative to onkeydown event :

onkeydown onkeypress onkeyup

Comments :onkeydown attribute does not apply to the following elements: , ,
, , ,