jquery simple way to get keyboard events _jquery

Source: Internet
Author: User

The examples in this article describe jquery's simple way to get keyboard events. Share to everyone for your reference, specific as follows:

When do we use to get keyboard events

When we do the web, we sometimes use keyboard events for a more human design. For example: the input box drop-down cue box, through the keyboard to choose what you want, Google's input box Drop-down prompts. When we browse the album, we can go through the keyboard around the key to view the photos. When we browse the novel, scrolling with the mouse is very easy to see which line, you can pass the keyboard up and down keys to the page, these small details are also very important. Doing a website is largely about handling details.

Two, jquery keyboard things function type

1. The KeyDown event is the event that is triggered when the keyboard is pressed
2. The KeyUp event is the event that is triggered when the key is pressed
3. The KeyPress event is the event that is triggered when the keyboard is pressed

KeyPress and KeyDown are similar in function, but differ in the content of getting events.

Ii. Illustrative examples

 
 

Iii. results of the test

1. In the above input box, enter a letter R, the first time will pop KeyDown, will prompt keypress
2. When we press the PG DN 銉, it pops up KeyUp and then pops KeyDown
3. When we press SHIFT+C, only the keypress will pop up.
4. When we press the Ctrl+alt, will not appear keypress, the first will appear two KeyDown, the second press, the first appear KeyUp, and then in the presence of KeyDown

There are many possibilities, we just have to try the usual 銉.

Iv. get the ASCII value of the keyboard event

<script type= "Text/javascript" >
 $ (' #search_input ')
 . KeyDown (function (event) {
 alert ( Event.keycode);
 })
</script>

More about jquery event Operations interested readers can view the site topics: "JQuery common event usage and skills summary"

I hope this article will help you with the jquery program design.

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.