Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hotkeys-js

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotkeys-js - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

4

dist/hotkeys.min.js

@@ -1,3 +0,3 @@

/*! hotkeys-js v2.0.1 | (c) 2016 | https://github.com/jaywcjlove/hotkeys.git */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.hotkeys=e()}}(function(){function n(e){m=e||"all"}function t(){return m||"all"}function o(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent&&e.attachEvent("on"+n,function(){t(window.event)})}function r(e){return"string"==typeof e&&(e=E(e)),x.indexOf(e)!==-1}function i(e){return x.slice(0)}function f(e){var n,o=e.keyCode||f.which||f.charCode,r=O["*"];if(x.indexOf(o)===-1&&x.push(o),93!==o&&224!==o||(o=91),o in C){C[o]=!0;for(var i in k)k[i]===o&&(g[i]=!0);if(!r)return}for(var f in C)C[f]=e[b[f]];if(g.filter.call(this,e)){if(n=t(),r)for(a=0;a<r.length;a++)r[a].scope===n&&l(e,r[a],n);if(o in O)for(var a=0;a<O[o].length;a++)l(e,O[o][a],n)}}function l(e,n,t){var o;if(n.scope===t||"all"===n.scope){o=n.mods.length>0;for(var r in C)(!C[r]&&n.mods.indexOf(+r)>-1||C[r]&&n.mods.indexOf(+r)===-1)&&(o=!1);(0!==n.mods.length||C[16]||C[18]||C[17]||C[91])&&!o&&"*"!==n.shortcut||n.method(e,n)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function a(e,n){for(var o,r,i=h(e),f=[],l=0;l<i.length;l++){if(o=i[l].split("+"),o.length>1&&(f=s(o)),e=o[o.length-1],e=E(e),void 0===n&&(n=t()),!O[e])return;for(var a=0;a<O[e].length;a++)r=O[e][a],r.scope===n&&u(r.mods,f)&&(O[e][a]={})}}function c(e){var n,t,o;for(n in O)for(t=O[n],o=0;o<t.length;)t[o].scope===e?t.splice(o,1):o++}function u(e,n){if(e.length!==n.length)return!1;for(var t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function d(e){var n=(e.target||e.srcElement).tagName;return!("INPUT"===n||"SELECT"===n||"TEXTAREA"===n)}function s(e){for(var n=e.slice(0,e.length-1),t=0;t<n.length;t++)n[t]=k[n[t]];return n}function h(e){var n;return e=e.replace(/\s/g,""),n=e.split(","),""===n[n.length-1]&&(n[n.length-2]+=","),n}function p(n){var t=n.keyCode||e.which||e.charCode,o=x.indexOf(t);if(o>=0&&x.splice(o,1),93!==t&&224!==t||(t=91),t in C){C[t]=!1;for(var r in k)k[r]===t&&(g[r]=!1)}}function g(e,n,t){var o=h(e),r=[],i=0;for(void 0===t&&(t=n,n="all");i<o.length;i++)e=o[i].split("+"),r=[],e.length>1&&(r=s(e),e=[e[e.length-1]]),e=e[0],e="*"===e?"*":E(e),e in O||(O[e]=[]),O[e].push({shortcut:o[i],scope:n,method:t,key:o[i],mods:r})}Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var n=0;n<this.length;n++)if(this[n]===e)return n;return-1});for(var v,y=navigator.userAgent.toLowerCase().indexOf("firefox")>0,w={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,home:36,end:35,pageup:33,pagedown:34,",":188,".":190,"/":191,"`":192,"-":y?173:189,"=":y?61:187,";":y?59:186,"'":222,"[":219,"]":221,"\\":220},m="all",k={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":y?224:91,command:y?224:91},x=[],b={16:"shiftKey",18:"altKey",17:"ctrlKey"},C={16:!1,18:!1,17:!1},E=function(e){return w[e]||e.toUpperCase().charCodeAt(0)},O={},A=1;A<20;A++)w["f"+A]=111+A;b[y?224:91]="metaKey",C[y?224:91]=!1,o(document,"keydown",function(e){f(e)}),o(document,"keyup",function(e){p(e)}),v={setScope:n,getScope:t,deleteScope:c,getPressedKeyCodes:i,isPressed:r,filter:d,unbind:a};for(var K in v)g[K]=v[K];var P=window.hotkeys;return g.noConflict=function(e){return e&&window.hotkeys===g&&(window.hotkeys=P),g},window.hotkeys=g,g});
/*! hotkeys-js v2.0.1 | (c) 2017 kenny wang <wowohoo@qq.com> | https://github.com/jaywcjlove/hotkeys.git */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).hotkeys=e()}}(function(){function n(){return h||"all"}function t(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent&&e.attachEvent("on"+n,function(){t(window.event)})}function o(e){var t,o=e.keyCode||e.which||e.charCode,i=m["*"];if(-1===g.indexOf(o)&&g.push(o),93!==o&&224!==o||(o=91),o in y){y[o]=!0;for(var f in p)p[f]===o&&(c[f]=!0);if(!i)return}for(var l in y)y[l]=e[v[l]];if(c.filter.call(this,e)){if(t=n(),i)for(a=0;a<i.length;a++)i[a].scope===t&&r(e,i[a],t);if(o in m)for(var a=0;a<m[o].length;a++)r(e,m[o][a],t)}}function r(e,n,t){var o;if(n.scope===t||"all"===n.scope){o=n.mods.length>0;for(var r in y)(!y[r]&&n.mods.indexOf(+r)>-1||y[r]&&-1===n.mods.indexOf(+r))&&(o=!1);(0!==n.mods.length||y[16]||y[18]||y[17]||y[91])&&!o&&"*"!==n.shortcut||!1===n.method(e,n)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function i(e,n){if(e.length!==n.length)return!1;for(var t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function f(e){for(var n=e.slice(0,e.length-1),t=0;t<n.length;t++)n[t]=p[n[t]];return n}function l(e){var n;return e=e.replace(/\s/g,""),""===(n=e.split(","))[n.length-1]&&(n[n.length-2]+=","),n}function a(n){var t=n.keyCode||e.which||e.charCode,o=g.indexOf(t);if(o>=0&&g.splice(o,1),93!==t&&224!==t||(t=91),t in y){y[t]=!1;for(var r in p)p[r]===t&&(c[r]=!1)}}function c(e,n,t){var o=l(e),r=[],i=0;for(void 0===t&&(t=n,n="all");i<o.length;i++)r=[],(e=o[i].split("+")).length>1&&(r=f(e),e=[e[e.length-1]]),(e="*"===(e=e[0])?"*":w(e))in m||(m[e]=[]),m[e].push({shortcut:o[i],scope:n,method:t,key:o[i],mods:r})}Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var n=0;n<this.length;n++)if(this[n]===e)return n;return-1});for(var u,d=navigator.userAgent.toLowerCase().indexOf("firefox")>0,s={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,home:36,end:35,pageup:33,pagedown:34,"⇪":20,CapsLock:20,",":188,".":190,"/":191,"`":192,"-":d?173:189,"=":d?61:187,";":d?59:186,"'":222,"[":219,"]":221,"\\":220},h="all",p={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":d?224:91,command:d?224:91},g=[],v={16:"shiftKey",18:"altKey",17:"ctrlKey"},y={16:!1,18:!1,17:!1},w=function(e){return s[e]||e.toUpperCase().charCodeAt(0)},m={},k=1;k<20;k++)s["f"+k]=111+k;v[d?224:91]="metaKey",y[d?224:91]=!1,t(document,"keydown",function(e){o(e)}),t(document,"keyup",function(e){a(e)}),u={setScope:function(e){h=e||"all"},getScope:n,deleteScope:function(e){var n,t,o;for(n in m)for(t=m[n],o=0;o<t.length;)t[o].scope===e?t.splice(o,1):o++},getPressedKeyCodes:function(e){return g.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=w(e)),-1!==g.indexOf(e)},filter:function(e){var n=(e.target||e.srcElement).tagName;return!("INPUT"===n||"SELECT"===n||"TEXTAREA"===n)},unbind:function(e,t){for(var o,r,a=l(e),c=[],u=0;u<a.length;u++){if((o=a[u].split("+")).length>1&&(c=f(o)),e=o[o.length-1],e=w(e),void 0===t&&(t=n()),!m[e])return;for(var d=0;d<m[e].length;d++)(r=m[e][d]).scope===t&&i(r.mods,c)&&(m[e][d]={})}}};for(var x in u)c[x]=u[x];var C=window.hotkeys;return c.noConflict=function(e){return e&&window.hotkeys===c&&(window.hotkeys=C),c},window.hotkeys=c,c});
{
"name": "hotkeys-js",
"version": "2.0.1",
"version": "2.0.2",
"description": "A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.",
"author": "kenny wang <wowohoo@qq.com>",
"main": "dist/hotkeys.min.js",
"scripts": {
"build:test": "browserify test/hotkeys.js | uglifyjs --compress --mangle > test/hotkeys.test.js",
"build:min": "umd hotkeys src/hotkeys.js | uglifyjs -mc | bannerjs -o > dist/hotkeys.min.js",
"build:dist": "umd hotkeys src/hotkeys.js | bannerjs -m | uglifyjs -b beautify=true --comments 'all' > dist/hotkeys.js ",
"build": "npm run build:min && npm run build:dist",
"test": "npm run build:test && ssr",
"watch": "onchange 'src/hotkeys.js' -v -- npm run build "

@@ -28,10 +31,12 @@ },

"bannerjs": "^1.0.5",
"browserify": "^13.1.1",
"onchange": "^3.2.0",
"browserify": "^14.4.0",
"jsdom": "^11.1.0",
"onchange": "^3.2.1",
"ssr": "^1.1.1",
"tape": "^4.6.3",
"tape": "^4.8.0",
"tape-dom": "0.0.12",
"uglify-js": "^2.7.5",
"uglify-js": "^3.0.27",
"umd": "^3.0.1"
}
},
"dependencies": {}
}
# 设置快捷键
[![](https://img.shields.io/github/issues/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/issues) [![](https://img.shields.io/github/forks/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/network) [![](https://img.shields.io/github/stars/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/stargazers) [![](https://img.shields.io/github/release/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/releases) [![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/chinese.svg)](http://jaywcjlove.github.io/hotkeys/?lang=cn) [![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/english.svg)](http://jaywcjlove.github.io/hotkeys/?lang=en)
[![](https://img.shields.io/github/issues/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/issues) [![](https://img.shields.io/github/forks/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/network) [![](https://img.shields.io/github/stars/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/stargazers) [![](https://img.shields.io/github/release/jaywcjlove/hotkeys.svg)](https://github.com/jaywcjlove/hotkeys/releases)
这是一个强健的 Javascript 库用于捕获键盘输入和输入的组合键,它没有依赖,压缩只有只有(~3kb)。`hotkey`是临摹大师[madrobby/keymaster](https://github.com/madrobby/keymaster)的作品,只是做了少许更改,添加UMD,和兼容问题。没有`fork`的原因是,不仅仅要一句一句的读懂,还要体现出临摹的作用。
这是一个强健的 Javascript 库用于捕获键盘输入和输入的组合键,它没有依赖,压缩只有只有(~3kb),gzip:1.9k。`hotkey` 可以算是临摹参考[madrobby/keymaster](https://github.com/madrobby/keymaster)的作品,重写了一遍,修复多个兼容问题,键支持,添加UMD支持和 **测试用例**,[官方文档DEMO预览](http://jaywcjlove.github.io/hotkeys/?lang=cn) [En](http://jaywcjlove.github.io/hotkeys/?lang=en)
[![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/chinese.svg)](http://jaywcjlove.github.io/hotkeys/?lang=cn) [![jaywcjlove/sb](https://jaywcjlove.github.io/sb/lang/english.svg)](http://jaywcjlove.github.io/hotkeys/?lang=en)

@@ -103,4 +104,4 @@ ```

`⇪` Caps Lock(大写)
`fn` 功能键就是fn(不支持)
`↩︎` return/Enter
~~`fn` 功能键就是fn(不支持)~~
`↩︎` return/enter
`space` 空格键

@@ -155,2 +156,3 @@

## 键判断
判断摁下的键是否为某个键

@@ -157,0 +159,0 @@

@@ -18,3 +18,3 @@ //IE对indexOf方法的支持

home: 36, end: 35,
pageup: 33, pagedown: 34,
pageup: 33, pagedown: 34,'⇪': 20,'CapsLock': 20,
',': 188, '.': 190, '/': 191,

@@ -75,5 +75,4 @@ '`': 192, '-': isff?173:189, '=': isff?61:187,

function dispatch (event) {
var key = event.keyCode || e.which || e.charCode,
var key = event.keyCode || event.which || event.charCode,
scope,asterisk = _handlers['*'];
//搜集绑定的键

@@ -80,0 +79,0 @@ if(_downKeys.indexOf(key)===-1) _downKeys.push(key);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc