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

keycon

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keycon - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

3

declaration/KeyController.d.ts
import Component from "@egjs/component";
export declare function getKey(keyCode: number): string;
export declare function getCombi(e: KeyboardEvent, key?: string): string[];
export declare function getModifierCombi(e: KeyboardEvent): string[];
export interface KeyControllerEvent {

@@ -16,3 +17,3 @@ inputEvent: KeyboardEvent;

private container;
static readonly global: KeyController;
static get global(): KeyController;
static setGlobal(): KeyController;

@@ -19,0 +20,0 @@ ctrlKey: boolean;

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/keycon.git
version: 1.0.0
version: 1.1.0
*/

@@ -13,14 +13,14 @@ import Component from '@egjs/component';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -362,7 +362,15 @@

var keys = [e.shiftKey && "shift", e.ctrlKey && "ctrl", e.altKey && "alt", e.metaKey && "meta"];
var keys = getModifierCombi(e);
keys.indexOf(key) === -1 && keys.push(key);
return keys.filter(Boolean);
}
/**
* @memberof KeyController
*/
function getModifierCombi(e) {
var keys = [e.shiftKey && "shift", e.ctrlKey && "ctrl", e.altKey && "alt", e.metaKey && "meta"];
return keys.filter(Boolean);
}
function getArrangeCombi(keys) {

@@ -453,3 +461,3 @@ var arrangeKeys = keys.slice();

},
enumerable: true,
enumerable: false,
configurable: true

@@ -558,3 +566,3 @@ });

export default KeyController;
export { getCombi, getKey };
export { getCombi, getKey, getModifierCombi };
//# sourceMappingURL=keycon.esm.js.map

@@ -7,5 +7,5 @@ /*

repository: git+https://github.com/daybrush/keycon.git
version: 1.0.0
version: 1.1.0
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@egjs/component"),require("@daybrush/utils")):"function"==typeof define&&define.amd?define(["@egjs/component","@daybrush/utils"],t):(e=e||self).keycon=t(e.eg.Component,e.utils)}(this,function(e,r){"use strict";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};var t,i,n=(function(e,t){function n(e){if(e&&"object"==typeof e){var t=e.which||e.keyCode||e.charCode;t&&(e=t)}if("number"==typeof e)return a[e];var n,r=String(e);return(n=o[r.toLowerCase()])?n:(n=i[r.toLowerCase()])||(1===r.length?r.charCodeAt(0):void 0)}n.isEventKey=function(e,t){if(e&&"object"==typeof e){var n=e.which||e.keyCode||e.charCode;if(null==n)return!1;if("string"==typeof t){var r;if(r=o[t.toLowerCase()])return r===n;if(r=i[t.toLowerCase()])return r===n}else if("number"==typeof t)return t===n;return!1}};var o=(t=e.exports=n).code=t.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},i=t.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91};for(r=97;r<123;r++)o[String.fromCharCode(r)]=r-32;for(var r=48;r<58;r++)o[r-48]=r;for(r=1;r<13;r++)o["f"+r]=r+111;for(r=0;r<10;r++)o["numpad "+r]=r+96;var a=t.names=t.title={};for(r in o)a[o[r]]=r;for(var u in i)o[u]=i[u]}(t={exports:{}},t.exports),t.exports),a=(n.code,n.codes,n.aliases,n.names),u=(n.title,{"+":"plus","left command":"meta","right command":"meta"}),s={shift:1,ctrl:2,alt:3,meta:4};function c(e){var t=a[e]||"";for(var n in u)t=t.replace(n,u[n]);return t.replace(/\s/g,"")}function f(e,t){void 0===t&&(t=c(e.keyCode));var n=[e.shiftKey&&"shift",e.ctrlKey&&"ctrl",e.altKey&&"alt",e.metaKey&&"meta"];return-1===n.indexOf(t)&&n.push(t),n.filter(Boolean)}function y(e){var t=e.slice();return t.sort(function(e,t){return(s[e]||5)-(s[t]||5)}),t}var l=function(n){function e(e){void 0===e&&(e=window);var t=n.call(this)||this;return t.container=e,t.ctrlKey=!1,t.altKey=!1,t.shiftKey=!1,t.metaKey=!1,t.clear=function(){return t.ctrlKey=!1,t.altKey=!1,t.shiftKey=!1,t.metaKey=!1,t},t.keydownEvent=function(e){t.triggerEvent("keydown",e)},t.keyupEvent=function(e){t.triggerEvent("keyup",e)},t.blur=function(){t.clear(),t.trigger("blur")},r.addEvent(e,"blur",t.blur),r.addEvent(e,"keydown",t.keydownEvent),r.addEvent(e,"keyup",t.keyupEvent),t}!function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(e,n);var t=e.prototype;return Object.defineProperty(e,"global",{get:function(){return i=i||new e},enumerable:!0,configurable:!0}),e.setGlobal=function(){return this.global},t.destroy=function(){var e=this.container;this.clear(),this.off(),r.removeEvent(e,"blur",this.blur),r.removeEvent(e,"keydown",this.keydownEvent),r.removeEvent(e,"keyup",this.keyupEvent)},t.keydown=function(e,t){return this.addEvent("keydown",e,t)},t.offKeydown=function(e,t){return this.removeEvent("keydown",e,t)},t.offKeyup=function(e,t){return this.removeEvent("keyup",e,t)},t.keyup=function(e,t){return this.addEvent("keyup",e,t)},t.addEvent=function(e,t,n){return r.isArray(t)?this.on(e+"."+y(t).join("."),n):r.isString(t)?this.on(e+"."+t,n):this.on(e,t),this},t.removeEvent=function(e,t,n){return r.isArray(t)?this.off(e+"."+y(t).join("."),n):r.isString(t)?this.off(e+"."+t,n):this.off(e,t),this},t.triggerEvent=function(e,t){this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey;var n=c(t.keyCode),r={key:n,isToggle:"ctrl"===n||"shift"===n||"meta"===n||"alt"===n,inputEvent:t,keyCode:t.keyCode,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey};this.trigger(e,r),this.trigger(e+"."+n,r);var o=f(t,n);1<o.length&&this.trigger(e+"."+o.join("."),r)},e}(e);return l.getKey=c,l.getCombi=f,l});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@egjs/component"),require("@daybrush/utils")):"function"==typeof define&&define.amd?define(["@egjs/component","@daybrush/utils"],t):(e=e||self).keycon=t(e.eg.Component,e.utils)}(this,function(e,a){"use strict";var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};var t,s,n=(function(e,t){function n(e){var t;if(!e||"object"!=typeof e||(t=e.which||e.keyCode||e.charCode)&&(e=t),"number"==typeof e)return a[e];var n=String(e),r=o[n.toLowerCase()];return r||((r=i[n.toLowerCase()])?r:1===n.length?n.charCodeAt(0):void 0)}n.isEventKey=function(e,t){if(e&&"object"==typeof e){var n=e.which||e.keyCode||e.charCode;if(null==n)return!1;if("string"==typeof t){var r=o[t.toLowerCase()];if(r)return r===n;if(r=i[t.toLowerCase()])return r===n}else if("number"==typeof t)return t===n;return!1}};for(var o=(t=e.exports=n).code=t.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},i=t.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91},r=97;r<123;r++)o[String.fromCharCode(r)]=r-32;for(var r=48;r<58;r++)o[r-48]=r;for(r=1;r<13;r++)o["f"+r]=r+111;for(r=0;r<10;r++)o["numpad "+r]=r+96;var a=t.names=t.title={};for(r in o)a[o[r]]=r;for(var u in i)o[u]=i[u]}(t={exports:{}},t.exports),t.exports),r=(n.code,n.codes,n.aliases,n.names),o=(n.title,{"+":"plus","left command":"meta","right command":"meta"}),i={shift:1,ctrl:2,alt:3,meta:4};function c(e){var t=r[e]||"";for(var n in o)t=t.replace(n,o[n]);return t.replace(/\s/g,"")}function f(e,t){void 0===t&&(t=c(e.keyCode));var n,r=[(n=e).shiftKey&&"shift",n.ctrlKey&&"ctrl",n.altKey&&"alt",n.metaKey&&"meta"].filter(Boolean);return-1===r.indexOf(t)&&r.push(t),r.filter(Boolean)}function l(e){var t=e.slice();return t.sort(function(e,t){return(i[e]||5)-(i[t]||5)}),t}var y=function(n){function e(){this.constructor=t}var t,r;function o(e){void 0===e&&(e=window);var t=n.call(this)||this;return t.container=e,t.ctrlKey=!1,t.altKey=!1,t.shiftKey=!1,t.metaKey=!1,t.clear=function(){return t.ctrlKey=!1,t.altKey=!1,t.shiftKey=!1,t.metaKey=!1,t},t.keydownEvent=function(e){t.triggerEvent("keydown",e)},t.keyupEvent=function(e){t.triggerEvent("keyup",e)},t.blur=function(){t.clear(),t.trigger("blur")},a.addEvent(e,"blur",t.blur),a.addEvent(e,"keydown",t.keydownEvent),a.addEvent(e,"keyup",t.keyupEvent),t}u(t=o,r=n),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e);var i=o.prototype;return Object.defineProperty(o,"global",{get:function(){return s=s||new o},enumerable:!1,configurable:!0}),o.setGlobal=function(){return this.global},i.destroy=function(){var e=this.container;this.clear(),this.off(),a.removeEvent(e,"blur",this.blur),a.removeEvent(e,"keydown",this.keydownEvent),a.removeEvent(e,"keyup",this.keyupEvent)},i.keydown=function(e,t){return this.addEvent("keydown",e,t)},i.offKeydown=function(e,t){return this.removeEvent("keydown",e,t)},i.offKeyup=function(e,t){return this.removeEvent("keyup",e,t)},i.keyup=function(e,t){return this.addEvent("keyup",e,t)},i.addEvent=function(e,t,n){return a.isArray(t)?this.on(e+"."+l(t).join("."),n):a.isString(t)?this.on(e+"."+t,n):this.on(e,t),this},i.removeEvent=function(e,t,n){return a.isArray(t)?this.off(e+"."+l(t).join("."),n):a.isString(t)?this.off(e+"."+t,n):this.off(e,t),this},i.triggerEvent=function(e,t){this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey;var n=c(t.keyCode),r={key:n,isToggle:"ctrl"===n||"shift"===n||"meta"===n||"alt"===n,inputEvent:t,keyCode:t.keyCode,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey};this.trigger(e,r),this.trigger(e+"."+n,r);var o=f(t,n);1<o.length&&this.trigger(e+"."+o.join("."),r)},o}(e);return y.getKey=c,y.getCombi=f,y});
//# sourceMappingURL=keycon.js.map

@@ -7,3 +7,3 @@ /*

repository: git+https://github.com/daybrush/keycon.git
version: 1.0.0
version: 1.1.0
*/

@@ -14,17 +14,17 @@ (function (global, factory) {

(global = global || self, global.keycon = factory());
}(this, function () { 'use strict';
}(this, (function () { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -656,7 +656,15 @@

var keys = [e.shiftKey && "shift", e.ctrlKey && "ctrl", e.altKey && "alt", e.metaKey && "meta"];
var keys = getModifierCombi(e);
keys.indexOf(key) === -1 && keys.push(key);
return keys.filter(Boolean);
}
/**
* @memberof KeyController
*/
function getModifierCombi(e) {
var keys = [e.shiftKey && "shift", e.ctrlKey && "ctrl", e.altKey && "alt", e.metaKey && "meta"];
return keys.filter(Boolean);
}
function getArrangeCombi(keys) {

@@ -747,3 +755,3 @@ var arrangeKeys = keys.slice();

},
enumerable: true,
enumerable: false,
configurable: true

@@ -856,3 +864,3 @@ });

}));
})));
//# sourceMappingURL=keycon.pkgd.js.map

@@ -7,5 +7,5 @@ /*

repository: git+https://github.com/daybrush/keycon.git
version: 1.0.0
version: 1.1.0
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).keycon=e()}(this,function(){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function f(t){return void 0===t}var t=function(){var t=function(){function t(){this._eventHandler={},this.options={}}var e=t.prototype;return e.trigger=function(t,e){void 0===e&&(e={});var n=this._eventHandler[t]||[];if(!(0<n.length))return!0;n=n.concat(),e.eventType=t;var r=!1,o=[e],i=0;e.stop=function(){r=!0},e.currentTarget=this;for(var a=arguments.length,f=new Array(2<a?a-2:0),u=2;u<a;u++)f[u-2]=arguments[u];for(1<=f.length&&(o=o.concat(f)),i=0;n[i];i++)n[i].apply(this,o);return!r},e.once=function(o,i){if("object"==typeof o&&f(i)){var t,e=o;for(t in e)this.once(t,e[t]);return this}if("string"==typeof o&&"function"==typeof i){var a=this;this.on(o,function t(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];i.apply(a,n),a.off(o,t)})}return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&f(e)){var n,r=t;for(n in r)this.on(n,r[n]);return this}if("string"==typeof t&&"function"==typeof e){var o=this._eventHandler[t];f(o)&&(this._eventHandler[t]=[],o=this._eventHandler[t]),o.push(e)}return this},e.off=function(t,e){if(f(t))return this._eventHandler={},this;if(f(e)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var n,r=t;for(n in r)this.off(n,r[n]);return this}var o,i,a=this._eventHandler[t];if(a)for(o=0;void 0!==(i=a[o]);o++)if(i===e){a=a.splice(o,1);break}return this},t}();return t.VERSION="2.1.2",t}();var e,n=(function(t,e){function n(t){if(t&&"object"==typeof t){var e=t.which||t.keyCode||t.charCode;e&&(t=e)}if("number"==typeof t)return a[t];var n,r=String(t);return(n=o[r.toLowerCase()])?n:(n=i[r.toLowerCase()])||(1===r.length?r.charCodeAt(0):void 0)}n.isEventKey=function(t,e){if(t&&"object"==typeof t){var n=t.which||t.keyCode||t.charCode;if(null==n)return!1;if("string"==typeof e){var r;if(r=o[e.toLowerCase()])return r===n;if(r=i[e.toLowerCase()])return r===n}else if("number"==typeof e)return e===n;return!1}};var o=(e=t.exports=n).code=e.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},i=e.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91};for(r=97;r<123;r++)o[String.fromCharCode(r)]=r-32;for(var r=48;r<58;r++)o[r-48]=r;for(r=1;r<13;r++)o["f"+r]=r+111;for(r=0;r<10;r++)o["numpad "+r]=r+96;var a=e.names=e.title={};for(r in o)a[o[r]]=r;for(var f in i)o[f]=i[f]}(e={exports:{}},e.exports),e.exports),o=(n.code,n.codes,n.aliases,n.names);n.title;function i(t){return Array.isArray(t)}function a(t){return"string"==typeof t}function u(t,e,n,r){t.addEventListener(e,n,r)}function s(t,e,n){t.removeEventListener(e,n)}var c,y={"+":"plus","left command":"meta","right command":"meta"},l={shift:1,ctrl:2,alt:3,meta:4};function h(t){var e=o[t]||"";for(var n in y)e=e.replace(n,y[n]);return e.replace(/\s/g,"")}function p(t,e){void 0===e&&(e=h(t.keyCode));var n=[t.shiftKey&&"shift",t.ctrlKey&&"ctrl",t.altKey&&"alt",t.metaKey&&"meta"];return-1===n.indexOf(e)&&n.push(e),n.filter(Boolean)}function d(t){var e=t.slice();return e.sort(function(t,e){return(l[t]||5)-(l[e]||5)}),e}var v=function(n){function t(t){void 0===t&&(t=window);var e=n.call(this)||this;return e.container=t,e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e.clear=function(){return e.ctrlKey=!1,e.altKey=!1,e.shiftKey=!1,e.metaKey=!1,e},e.keydownEvent=function(t){e.triggerEvent("keydown",t)},e.keyupEvent=function(t){e.triggerEvent("keyup",t)},e.blur=function(){e.clear(),e.trigger("blur")},u(t,"blur",e.blur),u(t,"keydown",e.keydownEvent),u(t,"keyup",e.keyupEvent),e}!function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(t,n);var e=t.prototype;return Object.defineProperty(t,"global",{get:function(){return c=c||new t},enumerable:!0,configurable:!0}),t.setGlobal=function(){return this.global},e.destroy=function(){var t=this.container;this.clear(),this.off(),s(t,"blur",this.blur),s(t,"keydown",this.keydownEvent),s(t,"keyup",this.keyupEvent)},e.keydown=function(t,e){return this.addEvent("keydown",t,e)},e.offKeydown=function(t,e){return this.removeEvent("keydown",t,e)},e.offKeyup=function(t,e){return this.removeEvent("keyup",t,e)},e.keyup=function(t,e){return this.addEvent("keyup",t,e)},e.addEvent=function(t,e,n){return i(e)?this.on(t+"."+d(e).join("."),n):a(e)?this.on(t+"."+e,n):this.on(t,e),this},e.removeEvent=function(t,e,n){return i(e)?this.off(t+"."+d(e).join("."),n):a(e)?this.off(t+"."+e,n):this.off(t,e),this},e.triggerEvent=function(t,e){this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey;var n=h(e.keyCode),r={key:n,isToggle:"ctrl"===n||"shift"===n||"meta"===n||"alt"===n,inputEvent:e,keyCode:e.keyCode,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey};this.trigger(t,r),this.trigger(t+"."+n,r);var o=p(e,n);1<o.length&&this.trigger(t+"."+o.join("."),r)},t}(t);return v.getKey=h,v.getCombi=p,v});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).keycon=t()}(this,function(){"use strict";var a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function f(e){return void 0===e}var e=function(){var e=function(){function e(){this._eventHandler={},this.options={}}var t=e.prototype;return t.trigger=function(e,t){void 0===t&&(t={});var n=this._eventHandler[e]||[];if(!(0<n.length))return!0;n=n.concat(),t.eventType=e;var r=!1,o=[t],i=0;t.stop=function(){r=!0},t.currentTarget=this;for(var a=arguments.length,f=new Array(2<a?a-2:0),u=2;u<a;u++)f[u-2]=arguments[u];for(1<=f.length&&(o=o.concat(f)),i=0;n[i];i++)n[i].apply(this,o);return!r},t.once=function(o,i){if("object"==typeof o&&f(i)){var e,t=o;for(e in t)this.once(e,t[e]);return this}var a;return"string"==typeof o&&"function"==typeof i&&(a=this).on(o,function e(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];i.apply(a,n),a.off(o,e)}),this},t.hasOn=function(e){return!!this._eventHandler[e]},t.on=function(e,t){if("object"==typeof e&&f(t)){var n,r=e;for(n in r)this.on(n,r[n]);return this}var o;return"string"==typeof e&&"function"==typeof t&&(f(o=this._eventHandler[e])&&(this._eventHandler[e]=[],o=this._eventHandler[e]),o.push(t)),this},t.off=function(e,t){if(f(e))return this._eventHandler={},this;if(f(t)){if("string"==typeof e)return this._eventHandler[e]=void 0,this;var n,r=e;for(n in r)this.off(n,r[n]);return this}var o=this._eventHandler[e];if(o)for(var i,a=0;void 0!==(i=o[a]);a++)if(i===t){o=o.splice(a,1);break}return this},e}();return e.VERSION="2.1.2",e}();var t,n=(function(e,t){function n(e){var t;if(!e||"object"!=typeof e||(t=e.which||e.keyCode||e.charCode)&&(e=t),"number"==typeof e)return a[e];var n=String(e),r=o[n.toLowerCase()];return r||((r=i[n.toLowerCase()])?r:1===n.length?n.charCodeAt(0):void 0)}n.isEventKey=function(e,t){if(e&&"object"==typeof e){var n=e.which||e.keyCode||e.charCode;if(null==n)return!1;if("string"==typeof t){var r=o[t.toLowerCase()];if(r)return r===n;if(r=i[t.toLowerCase()])return r===n}else if("number"==typeof t)return t===n;return!1}};for(var o=(t=e.exports=n).code=t.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},i=t.aliases={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91},r=97;r<123;r++)o[String.fromCharCode(r)]=r-32;for(var r=48;r<58;r++)o[r-48]=r;for(r=1;r<13;r++)o["f"+r]=r+111;for(r=0;r<10;r++)o["numpad "+r]=r+96;var a=t.names=t.title={};for(r in o)a[o[r]]=r;for(var f in i)o[f]=i[f]}(t={exports:{}},t.exports),t.exports),r=(n.code,n.codes,n.aliases,n.names);n.title;function u(e){return Array.isArray(e)}function s(e){return"string"==typeof e}function c(e,t,n,r){e.addEventListener(t,n,r)}function l(e,t,n){e.removeEventListener(t,n)}var y,o={"+":"plus","left command":"meta","right command":"meta"},i={shift:1,ctrl:2,alt:3,meta:4};function h(e){var t=r[e]||"";for(var n in o)t=t.replace(n,o[n]);return t.replace(/\s/g,"")}function p(e,t){void 0===t&&(t=h(e.keyCode));var n,r=[(n=e).shiftKey&&"shift",n.ctrlKey&&"ctrl",n.altKey&&"alt",n.metaKey&&"meta"].filter(Boolean);return-1===r.indexOf(t)&&r.push(t),r.filter(Boolean)}function d(e){var t=e.slice();return t.sort(function(e,t){return(i[e]||5)-(i[t]||5)}),t}var v=function(n){function e(){this.constructor=t}var t,r;function o(e){void 0===e&&(e=window);var t=n.call(this)||this;return t.container=e,t.ctrlKey=!1,t.altKey=!1,t.shiftKey=!1,t.metaKey=!1,t.clear=function(){return t.ctrlKey=!1,t.altKey=!1,t.shiftKey=!1,t.metaKey=!1,t},t.keydownEvent=function(e){t.triggerEvent("keydown",e)},t.keyupEvent=function(e){t.triggerEvent("keyup",e)},t.blur=function(){t.clear(),t.trigger("blur")},c(e,"blur",t.blur),c(e,"keydown",t.keydownEvent),c(e,"keyup",t.keyupEvent),t}a(t=o,r=n),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e);var i=o.prototype;return Object.defineProperty(o,"global",{get:function(){return y=y||new o},enumerable:!1,configurable:!0}),o.setGlobal=function(){return this.global},i.destroy=function(){var e=this.container;this.clear(),this.off(),l(e,"blur",this.blur),l(e,"keydown",this.keydownEvent),l(e,"keyup",this.keyupEvent)},i.keydown=function(e,t){return this.addEvent("keydown",e,t)},i.offKeydown=function(e,t){return this.removeEvent("keydown",e,t)},i.offKeyup=function(e,t){return this.removeEvent("keyup",e,t)},i.keyup=function(e,t){return this.addEvent("keyup",e,t)},i.addEvent=function(e,t,n){return u(t)?this.on(e+"."+d(t).join("."),n):s(t)?this.on(e+"."+t,n):this.on(e,t),this},i.removeEvent=function(e,t,n){return u(t)?this.off(e+"."+d(t).join("."),n):s(t)?this.off(e+"."+t,n):this.off(e,t),this},i.triggerEvent=function(e,t){this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey;var n=h(t.keyCode),r={key:n,isToggle:"ctrl"===n||"shift"===n||"meta"===n||"alt"===n,inputEvent:t,keyCode:t.keyCode,ctrlKey:t.ctrlKey,altKey:t.altKey,shiftKey:t.shiftKey,metaKey:t.metaKey};this.trigger(e,r),this.trigger(e+"."+n,r);var o=p(t,n);1<o.length&&this.trigger(e+"."+o.join("."),r)},o}(e);return v.getKey=h,v.getCombi=p,v});
//# sourceMappingURL=keycon.pkgd.min.js.map
{
"name": "keycon",
"version": "1.0.0",
"version": "1.1.0",
"description": "Keyboard Controller",

@@ -5,0 +5,0 @@ "main": "./dist/keycon.js",

@@ -32,3 +32,3 @@ import Component from "@egjs/component";

export function getCombi(e: KeyboardEvent, key: string = getKey(e.keyCode)): string[] {
const keys = [e.shiftKey && "shift", e.ctrlKey && "ctrl", e.altKey && "alt", e.metaKey && "meta"];
const keys = getModifierCombi(e);
keys.indexOf(key) === -1 && keys.push(key);

@@ -39,2 +39,11 @@

/**
* @memberof KeyController
*/
export function getModifierCombi(e: KeyboardEvent): string[] {
const keys = [e.shiftKey && "shift", e.ctrlKey && "ctrl", e.altKey && "alt", e.metaKey && "meta"];
return keys.filter(Boolean);
}
function getArrangeCombi(keys: string[]) {

@@ -41,0 +50,0 @@ const arrangeKeys = keys.slice();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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