Scene:
Shortcut keys need to be set on the page.
The following demo is a combination of key press events, can be used directly, a single keystroke response event, just want to change the key value if the need for keys can be, the example cited Baidu Static library of jquery resources, need to operate in a networked environment.
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "
pageencoding=" Utf-8 "%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
}
}
});
</script>
Jquery keyboard Events:
1. KeyDown ():
When the key is pressed, the event is triggered;
2. KeyUp ();
The event is triggered when the key is pressed and released;
3. KeyPress ();
When the keystroke is triggered, my understanding is to press the same key and release it immediately.
use:
$ (document). KeyDown (function (e) {
console.log (e.keycode); Gets the key code for the current key
Get the key code, we can do the corresponding logical judgment.
$ (document). KeyDown (function (event) {
var e = Event | | window.event;
var k = E.keycode | | E.which;
Switch (k) {case
:
//...
break;
Case:
//...
break;
return false;
})
Key code for commonly used keyboard events:
KeyCode 8 = BackSpace BackSpace
KeyCode 9 = Tab tab
KeyCode = Clear
KeyCode = Enter
KeyCode = shift_l
KeyCode = control_l
KeyCode = alt_l
KeyCode = Pause
KeyCode = Caps_lock
KeyCode = Escape escape
KeyCode = Space
KeyCode = Prior
KeyCode = Next
KeyCode = End
KeyCode = Home
KeyCode (Panax) = Left
KeyCode = up
KeyCode = Right
KeyCode = Down
KeyCode = Select
KeyCode = Print
KeyCode = Execute
KeyCode = Insert
KeyCode = Delete
KeyCode = Help
keycode = 0 Equal braceright
keycode = 1 Exclam onesuperior
KeyCode = 2 Quotedbl twosuperior
KeyCode Wuyi = 3 section Threesuperior
keycode = 4 Dollar
KeyCode = 5 percent
KeyCode = 6 Ampersand
keycode = 7 Slash braceleft
KeyCode = 8 Parenleft bracketleft
KeyCode = 9 Parenright bracketright
KeyCode = a A
KeyCode = b b
KeyCode = c C
KeyCode = d D
KeyCode = e e eurosign
KeyCode = f F
KeyCode = g g
KeyCode = h H
KeyCode = i I
KeyCode-J J
KeyCode = k K
KeyCode = l l
keycode = M M mu
KeyCode = n N
keycode = o O
KeyCode = P p
KeyCode Bayi = q q at
KeyCode = r R
KeyCode-S S
KeyCode = t T
KeyCode = u u
KeyCode = v V
KeyCode = w W
KeyCode = x x
keycode) = y y
KeyCode = Z Z
KeyCode = Kp_0 Kp_0
KeyCode Kp_1 kp_1
KeyCode = kp_2 kp_2
KeyCode = Kp_3 Kp_3
KeyCode = Kp_4 Kp_4
KeyCode = Kp_5 Kp_5
KeyCode 102 = Kp_6 Kp_6
KeyCode kp_7 kp_7
KeyCode = Kp_8 Kp_8
KeyCode = Kp_9 Kp_9
KeyCode kp_multiply kp_multiply
KeyCode = Kp_add Kp_add
KeyCode 108 = Kp_separator Kp_separator
KeyCode 109 = kp_subtract Kp_subtract
KeyCode = Kp_decimal Kp_decimal