The order of events related to the keydown event:

keydown - The key is on its way down

The keydown event occurs when a keyboard key is pressed down.

The keydown() method triggers the keydown event, or attaches a function to run when a keydown event occurs.


$(selector).keydown() - Trigger the keydown event for the selected elements. 

$(selector).keydown(function) - Attach a function to the keydown event. 


<!doctype html>
	<html lang="en">
		<meta charset="utf-8">

		<script src=""></script>
				$("input").css("background-color", "green");  
				$("input").css("background-color", "violet");  
			Write Anything: <input type="text">  

Keyup occurs when we release a key and Keydown occurs when we press a key on keyboard.