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.