HTML onkeydown Attribute

❮ HTML Attributes


<input type="text" onkeydown="myFunction()">


The onkeydown attribute specifies the script run when a user is pressing a key.

Related Keyboard Events

Standard Syntax

<element onkeydown="script">

Browser Support


Applies to:

The onkeydown attribute can be used on the following element:

Element Attribute
All HTML elements. onkeydown

Attribute Values

Value Description
script Specifies the script to be run on onkeydown
❮ HTML Attributes