This is a JQ plug-in that basically allows you to implement a shortcut key system similar to a local application. This plugin's name is Js-hotkeys, the name is very common, but the function is very powerful. This plugin can do the whole keyboard event processing, including F1-F12, del/home/pageup, tab and other special keys, as well as ALT, Shift, Ctrl, space and other key combinations, such as CTRL+SHIFT+F1, etc. It also supports all browsers under the Windows platform.
The JQ plug-in is based on another, more powerful JS class library, which can be seen in this article: Handling keyboard shortcuts in JavaScript.
The plug-in's invocation method is very simple, you can refer to the official instructions on Google Code: click here.
can also see the small lion's translation and summary, as follows.
Using BIND and Unbind for event binding, Syntax: View plain copy to clipboard print? Binding Event Trigger $ (expression). Bind (Types,options, func); Unbind event triggers $ (expression). Unbind (Types,options, func);
Binding Event Trigger
$ (expression). Bind (Types,options, func);
Unbind event triggers
$ (expression). Unbind (Types,options, func);
Expression: This is nothing to say, it refers to the DOM object. Types: The type of trigger (that is, when the event is triggered), currently supports KeyDown, KeyUp, and keypress three kinds. Options: Trigger parameters. There are two, one is combi, the other is disableininput. The former is the key combination to be bound, the value is the shortcode of the key, and the latter is a Boolean value that indicates whether the combi specified key is masked, if expression must be an input or textarea object, and the default value is False. Func: The function that is called when the combi specified in the options is triggered.
Example: View plain copy to clipboard print? Bind Ctrl + A shortcut key on the current page, triggering execution of the FN1 () function $ (document). Bind (' KeyDown ', ' Ctrl + A ', fn1 ()); The ' $ ' character entered in Input.foo is automatically replaced with ' € ' $ (' Input.foo '). Bind (' KeyUp ', ' $ ', function () {this. value = this. Value.repl Ace (' $ ', ' € '); }); Pressing CTRL + A in Div.foo will no longer execute the FN2 () function $ (' Div.foo '). Unbind (' KeyDown ', ' Ctrl + A ', fn2 ()); The ' a ' character $ (document) cannot be entered in the input and textarea of the current page. Bind (' KeyDown ', {combi: ' A ', disableininput:true}, Fn3 ());
Bind Ctrl + A shortcut key on the current page, triggering execution of the FN1 () function
$ (document). Bind (' KeyDown ', ' Ctrl + A ', fn1 ());
The ' $ ' character entered in Input.foo is automatically replaced with ' € '
$ (' Input.foo '). Bind (' KeyUp ', ' $ ', function () {
this.value = This.value.replace (' $ ', ' € ');
};
Pressing CTRL + A in Div.foo will no longer execute the FN2 () function
$ (' Div.foo '). Unbind (' KeyDown ', ' Ctrl + A ', fn2 ());
The ' a ' character $ (document) cannot be entered in the input and textarea of the current page
. bind (' KeyDown ', {combi: ' A ', disableininput:true}, Fn3 ());
But the little lion is always unsuccessful in testing the parameters of disableininput, and does not know why. Who knows the master trouble to teach. The little lion was tested with chrom.
Also note that the Shortcode write order of the key combinations is in alphabetical order and is case-insensitive.