KEYDOWN EVENT:
Triggering: The keydown event is triggered when a key on the keyboard is first pressed down.
Repetition: If a key is held down, the keydown event will be repeatedly triggered.
Order: The keydown event occurs before the corresponding keypress event.
USE CASE: It is commonly used to detect when a key is initially pressed down, and it provides information about which physical key was pressed.
KEYPRESS EVENT:
Triggering: The keypress event is triggered when a key generates a character, meaning when a key produces a printable character (letters, numbers, symbols).
Repetition: Unlike keydown, the keypress event does not repeat if a key is held down.
Order: The keypress event occurs after the corresponding keydown event.
USE CASE: It is often used to capture textual input and provides information about the character that was produced.