New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pluginjs/keyboard

Package Overview
Dependencies
Maintainers
2
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pluginjs/keyboard - npm Package Compare versions

Comparing version 0.7.4 to 0.7.5

4

dist/keyboard.common.js
/*!
* @pluginjs/keyboard v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/keyboard v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.

@@ -5,0 +5,0 @@ */

/*!
* @pluginjs/keyboard v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/keyboard v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var SimpleEmitter=_interopDefault(require("@pluginjs/simple-emitter")),utils=require("@pluginjs/utils");const MAP_BY_CODE={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"caps_lock",27:"esc",32:"space",33:"page_up",34:"page_down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"command",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"num_lock"},MAP_BY_NAME={};for(const t in MAP_BY_CODE)Object.prototype.hasOwnProperty.call(MAP_BY_CODE,t)&&(MAP_BY_NAME[MAP_BY_CODE[t]]=Number(t));const MODIFIERS={16:"shift",17:"ctrl",18:"alt",91:"command"};class Keyboard{constructor(t){this.element=t||window.document,this.emitter=new SimpleEmitter,this.initialize(),this.registerEvent()}initialize(){this.status={},utils.each(MODIFIERS,(t,e)=>{this.status[e]=!1,this.emitter.on(`${t}down`,()=>{this.status[e]||(this.status[e]=!0)}),this.emitter.on(`${t}up`,()=>{this.status[e]&&(this.status[e]=!1)})})}registerEvent(){const t=t=>this.handler(t);this.element.addEventListener("keydown",t),this.element.addEventListener("keyup",t)}handler(t){let e=t.keyCode;const s="keydown"===t.type?"down":"up";let i="";if(93!==e&&224!==e||(e=91),e in MODIFIERS){if(!1===this.emitter.emit(e+s))return!1}utils.each(this.status,(t,e)=>{e&&(i+=t)});const r=i+e+s;r in this.emitter.listeners&&!1===this.emitter.emit(r)&&(t.preventDefault(),t.stopPropagation())}on(t,e,s){return this.dispatch(!0,t,e,s)}off(t,e,s){return this.dispatch(!1,t,e,s)}dispatch(t,e,s,i){return this.parseKeys(this.processKey(s)).forEach(s=>{const r=s.modifiers,n=s.keyCode;let o="";if(null!==r)for(let t=0;t<r.length;t++)o+=MODIFIERS[r[t]];t?this.emitter.on(o+n+e,i):this.emitter.off(o+n+e,i)}),this}parseKeys(t){const e=[];return t.map(t=>{const s={};let i=null;const r=(t=t.split("+")).length;return r>1&&(i=this.processModifiers(t),t=[t[r-1]]),t=this.getKeyCode(t[0]),s.modifiers=i,s.keyCode=t,e.push(s),t}),e}processKey(t){const e=(t=t.toLowerCase().replace(/\s/g,"")).split(",");return""===e[e.length-1]&&(e[e.length-2]+=","),e}processModifiers(t){const e=t.slice(0,t.length-1);for(let t=0;t<e.length;t++)e[t]=MAP_BY_NAME[e[t]];return e.sort(),e}distribute(t,e,s){return null==s?this.off(t,e,s):this.on(t,e,s)}getKeyName(t){return MAP_BY_CODE[t]}getKeyCode(t){return MAP_BY_NAME[t]}up(t,e){return this.distribute("up",t,e)}down(t,e){return this.distribute("down",t,e)}static of(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return new this(...e)}}const keyboard=function(){return Keyboard.of(...arguments)};module.exports=keyboard;
/*!
* @pluginjs/keyboard v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/keyboard v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.

@@ -5,0 +5,0 @@ */

/*!
* @pluginjs/keyboard v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/keyboard v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
import SimpleEmitter from"@pluginjs/simple-emitter";import{each}from"@pluginjs/utils";const MAP_BY_CODE={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"caps_lock",27:"esc",32:"space",33:"page_up",34:"page_down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"command",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"num_lock"},MAP_BY_NAME={};for(const t in MAP_BY_CODE)Object.prototype.hasOwnProperty.call(MAP_BY_CODE,t)&&(MAP_BY_NAME[MAP_BY_CODE[t]]=Number(t));const MODIFIERS={16:"shift",17:"ctrl",18:"alt",91:"command"};class Keyboard{constructor(t){this.element=t||window.document,this.emitter=new SimpleEmitter,this.initialize(),this.registerEvent()}initialize(){this.status={},each(MODIFIERS,(t,e)=>{this.status[e]=!1,this.emitter.on(`${t}down`,()=>{this.status[e]||(this.status[e]=!0)}),this.emitter.on(`${t}up`,()=>{this.status[e]&&(this.status[e]=!1)})})}registerEvent(){const t=t=>this.handler(t);this.element.addEventListener("keydown",t),this.element.addEventListener("keyup",t)}handler(t){let e=t.keyCode;const s="keydown"===t.type?"down":"up";let i="";if(93!==e&&224!==e||(e=91),e in MODIFIERS){if(!1===this.emitter.emit(e+s))return!1}each(this.status,(t,e)=>{e&&(i+=t)});const r=i+e+s;r in this.emitter.listeners&&!1===this.emitter.emit(r)&&(t.preventDefault(),t.stopPropagation())}on(t,e,s){return this.dispatch(!0,t,e,s)}off(t,e,s){return this.dispatch(!1,t,e,s)}dispatch(t,e,s,i){return this.parseKeys(this.processKey(s)).forEach(s=>{const r=s.modifiers,n=s.keyCode;let o="";if(null!==r)for(let t=0;t<r.length;t++)o+=MODIFIERS[r[t]];t?this.emitter.on(o+n+e,i):this.emitter.off(o+n+e,i)}),this}parseKeys(t){const e=[];return t.map(t=>{const s={};let i=null;const r=(t=t.split("+")).length;return r>1&&(i=this.processModifiers(t),t=[t[r-1]]),t=this.getKeyCode(t[0]),s.modifiers=i,s.keyCode=t,e.push(s),t}),e}processKey(t){const e=(t=t.toLowerCase().replace(/\s/g,"")).split(",");return""===e[e.length-1]&&(e[e.length-2]+=","),e}processModifiers(t){const e=t.slice(0,t.length-1);for(let t=0;t<e.length;t++)e[t]=MAP_BY_NAME[e[t]];return e.sort(),e}distribute(t,e,s){return null==s?this.off(t,e,s):this.on(t,e,s)}getKeyName(t){return MAP_BY_CODE[t]}getKeyCode(t){return MAP_BY_NAME[t]}up(t,e){return this.distribute("up",t,e)}down(t,e){return this.distribute("down",t,e)}static of(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return new this(...e)}}const keyboard=function(){return Keyboard.of(...arguments)};export default keyboard;
/*!
* @pluginjs/keyboard v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/keyboard v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.

@@ -5,0 +5,0 @@ */

/*!
* @pluginjs/keyboard v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/keyboard v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@pluginjs/simple-emitter"),require("@pluginjs/utils")):"function"==typeof define&&define.amd?define(["@pluginjs/simple-emitter","@pluginjs/utils"],t):e["@pluginjs/keyboard"]=t(e["@pluginjs/simple-emitter"],e["@pluginjs/utils"])}(this,function(e,t){"use strict";function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var u=new(Function.bind.apply(e,i));return n&&r(u,n.prototype),u}).apply(null,arguments)}e=e&&e.hasOwnProperty("default")?e.default:e;var u={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"caps_lock",27:"esc",32:"space",33:"page_up",34:"page_down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"command",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"num_lock"},o={};for(var s in u)Object.prototype.hasOwnProperty.call(u,s)&&(o[u[s]]=Number(s));var a={16:"shift",17:"ctrl",18:"alt",91:"command"},f=function(){function r(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.element=t||window.document,this.emitter=new e,this.initialize(),this.registerEvent()}var s,f,c;return s=r,c=[{key:"of",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i(this,t)}}],(f=[{key:"initialize",value:function(){var e=this;this.status={},t.each(a,function(t,n){e.status[n]=!1,e.emitter.on("".concat(t,"down"),function(){e.status[n]||(e.status[n]=!0)}),e.emitter.on("".concat(t,"up"),function(){e.status[n]&&(e.status[n]=!1)})})}},{key:"registerEvent",value:function(){var e=this,t=function(t){return e.handler(t)};this.element.addEventListener("keydown",t),this.element.addEventListener("keyup",t)}},{key:"handler",value:function(e){var n=e.keyCode,r="keydown"===e.type?"down":"up",i="";if((93!==n&&224!==n||(n=91),n in a)&&!1===this.emitter.emit(n+r))return!1;t.each(this.status,function(e,t){t&&(i+=e)});var u=i+n+r;u in this.emitter.listeners&&(!1===this.emitter.emit(u)&&(e.preventDefault(),e.stopPropagation()))}},{key:"on",value:function(e,t,n){return this.dispatch(!0,e,t,n)}},{key:"off",value:function(e,t,n){return this.dispatch(!1,e,t,n)}},{key:"dispatch",value:function(e,t,n,r){var i=this;return this.parseKeys(this.processKey(n)).forEach(function(n){var u=n.modifiers,o=n.keyCode,s="";if(null!==u)for(var f=0;f<u.length;f++)s+=a[u[f]];e?i.emitter.on(s+o+t,r):i.emitter.off(s+o+t,r)}),this}},{key:"parseKeys",value:function(e){var t=this,n=[];return e.map(function(e){var r={},i=null,u=(e=e.split("+")).length;return u>1&&(i=t.processModifiers(e),e=[e[u-1]]),e=t.getKeyCode(e[0]),r.modifiers=i,r.keyCode=e,n.push(r),e}),n}},{key:"processKey",value:function(e){var t=(e=e.toLowerCase().replace(/\s/g,"")).split(",");return""===t[t.length-1]&&(t[t.length-2]+=","),t}},{key:"processModifiers",value:function(e){for(var t=e.slice(0,e.length-1),n=0;n<t.length;n++)t[n]=o[t[n]];return t.sort(),t}},{key:"distribute",value:function(e,t,n){return null==n?this.off(e,t,n):this.on(e,t,n)}},{key:"getKeyName",value:function(e){return u[e]}},{key:"getKeyCode",value:function(e){return o[e]}},{key:"up",value:function(e,t){return this.distribute("up",e,t)}},{key:"down",value:function(e,t){return this.distribute("down",e,t)}}])&&n(s.prototype,f),c&&n(s,c),r}();return function(){return f.of.apply(f,arguments)}});

@@ -14,3 +14,3 @@ {

},
"version": "0.7.4",
"version": "0.7.5",
"category": "core",

@@ -37,10 +37,10 @@ "main": "dist/keyboard.common.js",

"dependencies": {
"@pluginjs/dom": "^0.7.4",
"@pluginjs/simple-emitter": "^0.7.4",
"@pluginjs/utils": "^0.7.4"
"@pluginjs/dom": "^0.7.5",
"@pluginjs/simple-emitter": "^0.7.5",
"@pluginjs/utils": "^0.7.5"
},
"devDependencies": {
"@babel/core": "^7.1.5",
"@babel/core": "^7.2.2",
"@pluginjs/browserslist-config": "^1.2.2",
"@pluginjs/cli": "^0.7.4",
"@pluginjs/cli": "^0.7.5",
"babel-jest": "*",

@@ -72,3 +72,3 @@ "jest": "*",

"title": "Plugin",
"gitHead": "15dd296725c971ec08d33abd1c655b205a52ade6"
"gitHead": "a5b515ae1dc38f5f84fb18c70c322d361050593c"
}
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