JS set the combination shortcut key/tabindex function Method _javascript Skill

Source: Internet
Author: User

Shortcut keys in the daily use is still quite a lot of, for example, familiar paste Ctrl + V, copy Ctrl + C, use shortcut keys to improve our efficiency, especially when we are familiar with an operation, it will become very convenient to use it again, very handy, for the use of the keyboard heavy users, The keyboard is always faster than the mouse.

1) TabIndex:

is to use the tab to easily control the links and form elements in the page
Its usage is very simple: Obj.tabindex = TabIndex; The value of this tabindex, according to the rules of the consortium can start from 0 to 32767

2 JS set combination shortcut key

The essence is to get the value of the keycode of the key you want to set, and if you want to add a ctrl,alt,shift, then a ctrlkey,altkey,shiftkey is added to judge, so the key is the KeyCode value

(1) Set CTRL +enter Submit
if (e.ctrlkey && e.keycode = 13) {
return submit ();
}

(2) Set ALT + Direction key ←
if (e.altkey&& E.keycode = = 37) {
return submit ();
}

(3) Set SHIFT+F10
if (e.shiftkey&& E.keycode = = 37) {
return submit ();
}

4) Set EN
ter submit
if (E.keycode = = 13) {
return submit ();
}

There are some common shortcut keys attached here:
keycode    8 = BackSpace BackSpace
keycode    9 = tab TAB
keycode   = Clear
keycode   = Enter
keycode   = shift_l
keycode & nbsp control_l
keycode   = alt_l
keycode   = Pause
keycode   = caps_lock< br>keycode   = Escape escape
keycode   = space spaces
keycode   = Prior
Ke ycode   = Next
keycode   = end
keycode   = home
keycode   Panax Notoginseng = L EFT
keycode   = up
keycode  -right
keycode   = down
keycode & nbsp Select
keycode   = Print
keycode   = Execute
keycode   = Insert
K eycode   = Delete
keycode   = Help
Note: Browser compatibility issues

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.