Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report