Enhance user experience and set shortcuts

Source: Internet
Author: User

There are still a lot of shortcut keys in daily use, such as pasting Ctrl + V and copying Ctrl + C. Using the shortcut keys can improve our work efficiency, especially when we are familiar with an operation, it is very convenient and convenient to use it again. For heavy users who use the keyboard,

The keyboard is always faster than the mouse.

This article mainly mentions setting tabindex and JS combination shortcut keys using JS methods.

1) tabindex:

Is to use the tab to easily control the links and form elements in the page.

Its usage is simple: obj. tabindex = tabindex; the value of tabindex can start from 0 to 32767 according to W3C rules.

This is relatively simple. The key is to understand his role. I will not give an example here. Here is an articleArticleThe Study of tabindex is very careful.

Http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/

2) Set combination shortcut keys in JS

The essence is to obtain the keycode value of the key you want to set. If you want to add Ctrl, ALT, shift, add a ctrlkey, altkey, and shiftkey to judge, so the key lies in the keycode value.

(1) set Ctrl + enter to submit

If (E. ctrlkey & E. keycode = 13 ){
Return submit ();
}

(2) Set Alt + direction keys

If (E.Altkey& Amp; E. keycode =37){
Return submit ();
}

(3) settingsShift + F10

If (E. shiftkey & E. keycode = 37 ){
Return submit ();
}

(4) set enter to submit

If (E. keycode = 13 ){
Return submit ();
}

Some common shortcut keys are appended here:

Keycode 8 = 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
Keycode 32 = space
Keycode 33 = 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 = Execute
Keycode 45 = insert
Keycode 46 = Delete
Keycode 47 = 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.