Change the background color of an input field each time a key is pressed:
A key press has two parts: 1. The key is pressed down. 2. The key is released.
The keydown event occurs when a keyboard key is pressed down.
The keydown() method triggers the keydown event, or specifies a function to run when a keydown event occurs.
Tip: Use the event.which property to return which key was pressed.
Trigger the keydown event for the selected elements.
Specifies a function to run when the keydown event occurs for the selected elements.
| Parameter | Description |
|---|---|
| function | Optional. Specifies the function to run when the keydown event occurs |
Determine which key was pressed
How to determine which key was pressed.
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $3.98 Unlimited Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| Download XML Editor |
| FREE Website BUILDER |
| Best Website Templates Top CSS Templates |
| CREATE HTML Websites |
| EASY WEBSITE BUILDER |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|