Get the App
SLTechnology News&Howtos  ›  Development  › 

How to analyze the JavaScript class library keyboard.js that can add shortcut key combinations

Shulou Source: shulou.com Published: 2022-06-02 14:12:36 10月05日 Update

This article introduces how to understand the JavaScript class library keyboard.js, which can add shortcut key combinations, the content is very detailed, interested friends can refer to it, I hope it can be helpful to you.

Today to share a help in the website or web applications to add shortcut key combination of the class library-keyboard.js, using this class library you can easily capture the combination of input keys, can help you add related shortcut key operation, I hope you like it!

Main features:

◆ independent class library, of course, can also be used in combination with other class libraries, for example, jQuery

◆ letter or letter combination binding

◆ supports Callback callback

◆ multilingual support

◆ supports AMD loading, such as RequireJS

◆ documentation is complete

Javascript:

$(document) .ready (function () {var gbin1 = ['galled,' baked, 'ified,' nasty,'1'], google = ['GetWord,' oiled, 'oily,' galled, 'lumped,' e'], baidu = ['baked,' axed, 'ified,' dumped,'u'], kI = 0 Document.addEventListener ('keydown', function () {var keys = KeyboardJS.activeKeys (); if (keys.length) {for (var I = 0; I)

< keys.length; i += 1) { if(keys[i] === gbin1[kI]) { if(kI < gbin1.length - 1) { kI += 1; } else { $("#info").html("Loading gbin1.com ... ..."); location = "http://www.gbin1.com"; } } else if(keys[i] === google[kI]) { if(kI < gbin1.length - 1) { kI += 1; } else { $("#info").html("Loading gbin1.com ... ..."); location = "http://www.google.com"; } } else if(keys[i] === baidu[kI]) { if(kI < gbin1.length - 1) { kI += 1; } else { $("#info").html("Loading gbin1.com ... ..."); location = "http://www.baidu.com"; } } else{ kI = 0; } var keysString; keysString = keys.join(', '); if(keysString!=' '){ var log=$("#log"); log.append('' + keysString + '').find("b").last().show(); } } } }); }); HTML

Please typing one of site names below: gbin1 google baidu Status bar

CSS

Body {background: # ccc;} # container {margin: 0 auto; background: # 202020; width: 960px; color: # E3E3E3; padding: 15px; margin-top: 0;} h3 {font-size:16px; font-family: Arial; font-weight: normal;} # log b {position:relative;} # info {background: # 303030 Padding: 10px; font-size: 10px; color: # 888;} on how to understand the JavaScript class library keyboard.js that can add shortcut key combinations, this is it. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Combinations shortcuts help support content letters more good interests other categories guys buddies documents articles features knowledge articles websites multilingual references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MariaDB macOS Huawei Apple