Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
KeyDown: Occurs when the key is pressed while the control has focus.
KeyPress: Occurs when the key is pressed while the control has focus.
KeyUp: Occurs when a key is released while the control has focus.
1, KeyPress mainly used to receive letters, numbers and other ANSI characters
KeyDown and KeyUP event procedures can usually capture the keyboard except PRSCRN all keys (special keys for special keyboards are not discussed here
2, KeyPress can only capture a single character
KeyDown and KeyUp can capture key combinations.
3, KeyPress does not show the physical state of the keyboard (Shift key), but only passing a character. KeyPress the large and lowercase form of each character as a different key code solution
Interpretation, that is, as two different characters.
KeyDown and KeyUp cannot determine the size of key-value letters. KeyDown and KeyUp explain the uppercase and lowercase forms of each character with two parameters: keycode-
The physical keys (returning A and a as the same key) and shift-indicate the state of the SHIFT + key key and return either a or a.
5, KeyPress does not distinguish between the keypad and the main keyboard numeric characters.
KeyDown and KeyUp distinguish the numeric characters of the keypad and the main keyboard.
6, KeyDown, KeyUp event occurs when a key is pressed (KeyDown) or released (KEYUP).
Because the keyboard usually press the key will be immediately released (this is different from the mouse), so the two events using which difference is not.
Also, the up and the other two have a difference: to determine the state of the key modified must use up.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.