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

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

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: , ,
, , ,