Differences and connections between javascriptKeyDown, KeyPress, and KeyUp events

Source: Internet
Author: User
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"
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.