Js set the method to combine the shortcut key and tabindex function

  • 2020-03-29 23:55:32
  • OfStack

Shortcuts in daily use are many, such as familiar with paste, CTRL + v to copy CTRL + c, use keyboard shortcuts to improve our work efficiency, especially when we are familiar with a kind of operation, use it to operate again become very convenient, very comfortable, for heavy users using the keyboard, the keyboard will always faster than the mouse.

1) tabindex:

Tabs are used to easily control links and form elements in a page
Its usage is simple: obj. = tabindex; The value of this tabindex, according to w3c, can start from 0 to 32767

2) js set combination shortcut keys

It's essentially getting the value of the keyCode of the key that you're going to set, and if you're going to CTRL, Alt, shift, you're going to add a ctrlkey, altKey, shiftKey, so the key is the value of the keyCode

(1) set CTRL +enter to submit
If (e.c.trlkey && e.k.eycode == 13){
Return the submit ();
}

(2) set up   Alt+ direction key please
If (e.altKey&& e.keyCode == 37){
Return the submit ();
}

(3) set up   Shift + F10
If (e.hiftkey && e.eycode == 37){
Return the submit ();
}

4) set the en
Ter to submit
If (e.k eyCode = = 13) {
Return the submit ();
}

Here are some common shortcuts:
Keycode      8 = BackSpace BackSpace
Keycode      9 = Tab Tab
Keycode    12 = Clear
Keycode    13 = Enter
Keycode    16 = Shift_L
Keycode    17 = Control_L
Keycode    18 = Alt_L
Keycode    19 = Pause
Keycode    20 = Caps_Lock
Keycode    27 = Escape the Escape
Keycode    32 = space space
Keycode    33 = the Prior
Keycode    34 = Next
Keycode    35 = End
Keycode    36 = Home
Keycode    37 = Left
Keycode    38 = Up
Keycode    39 = Right
Keycode    40 = Down
Keycode    41 = Select
Keycode    42 = Print
Keycode    43 = the Execute
Keycode    45 = Insert
Keycode    46 = Delete
Keycode    47 = Help
Note: browser compatibility issues


Related articles: