Difference and link between javascriptKeyDown, KeyPress, and KeyUp events KeyDown: occurs when the control has focus. KeyPress: The Key is pressed when the control has focus. KeyUp: when the control has focus, the key is released. 1. KeyPress is mainly used... SyntaxHigh
Differences and connections between javascript KeyDown, KeyPress, and KeyUp events
KeyDown: The Key is pressed when the control has focus.
KeyPress: The Key is pressed when the control has focus.
KeyUp: when the control has focus, the key is released.
1. KeyPress is mainly used to receive ANSI characters such as letters and numbers
KeyDown and KeyUP events can usually capture all the buttons except PrScrn (the special keys of the special keyboard are not discussed here
2. KeyPress can only capture a single character
KeyDown and KeyUp can capture the combination of keys.
3. KeyPress does not display the physical status (SHIFT key) of the keyboard, but only transmits one character.
KeyPress uses the big and lowercase characters of each character as different key code interpretations, that is, two different characters.
KeyDown and KeyUp cannot determine the size of key-value letters. KeyDown and KeyUp use two parameters to explain the upper and lower case formats of each character: keycode-display the physical key (Return A and a as the same key) and shift-indicate the status of shift + key and return one of A or.
5. KeyPress does not distinguish between the numbers on the keypad and the primary keypad.
KeyDown and KeyUp distinguish between numbers on the keypad and the primary keypad.
6. A KeyDown or KeyUp event occurs when a key is pressed or released.
Generally, when you press the keyboard key, the keyboard is usually opened immediately (different from the mouse). Therefore, there is little difference between the two events. In addition, up is different from the other two: To determine the status after the key is modified, up must be used.
Author "867551603-qq-com"