Keyboard event keydown, keypress, keyup Summary

Source: Internet
Author: User
English input method: Event trigger sequence: keydown-> keypress-> keyup


Chinese Input Method: firfox: Input triggers keydown. Press enter to confirm input triggers keyupchrome: Input triggers keydown and keyup. Press enter to confirm that the input only triggers keydownie: Input triggers keydown and keyup, and press enter to confirm that the input triggers keydown, keyupsafari: keydown and keyup triggered by input. Press enter to confirm that the input triggers keydown. keyupopera: the input triggers keydown and keyup. Press enter to confirm that the input triggers keydown. The keyup keypress event does not support system function keys (for example: return, delete, and so on, where the Chinese input method cannot be effectively responded) for normal response, keydown and keyup can both effectively intercept the system function key, but the event interception location is different. The keys in the keyboard are divided into character (printable) keys and function keys (non-printable). The system function keys include: ESC, tab, Caps Lock, shift, Ctrl, ALT, enter, backspace, print screen, scroll lock, pause break, insert, delete, home, end, page up, page down, f1 through F12, num lock, the arrow keys. Keypress: Firefox: supports ESC, enter, backspace, pause break, insert, delete, home, end, page up, page down, F1 through F12, the arrow keyschrome: support for enteroprea: Support for entersafari: Support for enterie: Support for ESC, enter PS: Firefox: the upper and lower keys will trigger kepress. chrome: the upper and lower left keys do not trigger kepress. oprea: the up and down keys do not trigger kepress. safari: the upper and lower left keys do not trigger kepress. IE: the upper and lower left keys do not trigger kepress. ========================================================== ========================================================== keycode (Key Code), which, charcode (character encoding) keydown: Get keycode, charcode = 0 keypress: character (English case sensitive + number /*,.... keycode = 0. Obtain the charcode value. Otherwise, obtain the keycode, charcode = 0 keyup: Obtain the event in keycode, charcode = 0 jquery. which = original. charcode! = NULL? Original. charcode: original. keycode; Conclusion: Press enter, top, bottom, left, and other function keys keydown, keypress, keyup all get keycode, and the value is equal. When uppercase is enabled, keydown, keypress (letters, numbers on the primary keyboard, and press Enter), keyup, and which values are equal. The which obtained by lower case kepress is different from keypress and keyup. The keycode of the keypress event is case sensitive to letters, while the which values of the keydown and keyup events are not sensitive to keypress events. They cannot distinguish between the numeric keys on the primary key disk and the numeric keys attached to the keyboard, the which values of keydown and keyup are sensitive to the numeric keys of the Primary and Secondary keyboards. (Ie (less than ie9) has only one attribute keycode attribute. When the keydown and keyup events are, the keycode attribute indicates the key you press (also known as virtual keycode ), when a keypress event is captured, the keycode attribute indicates that the character (character code) You typed is different in the standard browser. The event object contains a keycode attribute and a charcode attribute, during keydown and keyup events, keycode indicates the key you press. charcode is 0. When a keypress event is captured, keycode is 0, charcode refers to the character you press. In view of the difference between IE and FF, if you are lazy, it is recommended to use only keydow and keyup events/** the browsers involved in this article (except IE) are the latest version **/Reference URL: http://www.cnblogs.com/leolai/archive/2012/08/01/2618386.html

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.