Home Web Front-end JS Tutorial How to set the combined shortcut key/tabindex function in js_javascript skills

How to set the combined shortcut key/tabindex function in js_javascript skills

May 16, 2016 pm 05:13 PM

There are still many shortcut keys used in daily life, such as the familiar paste ctrl v and copy ctrl c. Using shortcut keys can improve the efficiency of our work, especially when we are familiar with an operation and use it again. The operation will become very convenient and smooth. For heavy keyboard users, the keyboard will always be faster than the mouse.

1) tabindex:

is to use tab to easily control links and form elements on the page
Its usage is very simple: obj.tabindex = tabindex; this tabindex The value, according to w3c regulations, can start from 0 and go to 32767

2) js setting combination shortcut keys

The essence is to get the keyCode value of the key you want to set. If you want to add ctrl, alt, shift, then add a ctrlkey , altKey, shiftKey to judge, so the key lies in the value of keycode

(1) Set ctrl enter to submit
if (e.ctrlKey && e.keyCode == 13){
return submit();
}

(2) Set the 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();
}

Here are some common shortcut keys:
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 Escape
keycode 32 = space 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 Question

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Replace String Characters in JavaScript Replace String Characters in JavaScript Mar 11, 2025 am 12:07 AM

Replace String Characters in JavaScript

Custom Google Search API Setup Tutorial Custom Google Search API Setup Tutorial Mar 04, 2025 am 01:06 AM

Custom Google Search API Setup Tutorial

Example Colors JSON File Example Colors JSON File Mar 03, 2025 am 12:35 AM

Example Colors JSON File

8 Stunning jQuery Page Layout Plugins 8 Stunning jQuery Page Layout Plugins Mar 06, 2025 am 12:48 AM

8 Stunning jQuery Page Layout Plugins

10 jQuery Syntax Highlighters 10 jQuery Syntax Highlighters Mar 02, 2025 am 12:32 AM

10 jQuery Syntax Highlighters

Build Your Own AJAX Web Applications Build Your Own AJAX Web Applications Mar 09, 2025 am 12:11 AM

Build Your Own AJAX Web Applications

What is 'this' in JavaScript? What is 'this' in JavaScript? Mar 04, 2025 am 01:15 AM

What is 'this' in JavaScript?

10  JavaScript & jQuery MVC Tutorials 10 JavaScript & jQuery MVC Tutorials Mar 02, 2025 am 01:16 AM

10 JavaScript & jQuery MVC Tutorials

See all articles