Jquery adds the shortcut key for the page. Example _ jquery

Source: Internet
Author: User
This article describes how to add shortcuts to pages by jquery. For more information, see The Code is as follows:


$ (Document). keydown (function (e ){
If (e. which = 37 ){
Alert ("Left ");
}
If (e. which = 39 ){
Alert ("right ");
}
});

In addition, a keypress event is similar to a keydown event, but cannot be mixed. The difference between keydown and keypress is:

1 only character buttons can trigger keypress events, any button can trigger keydown events, such as: F1-F12, direction keys, etc. can only use keydown.

2. keydown returns the code of the keyboard, and keypress returns the ASCII character. For example, if the keydown character is a, keydown returns 65, and keypress returns 97.

If you want to check Ctrl, Shift, and other key combinations to determine whether these objects are true: e. shiftKey, e. ctrlKey

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.