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.3.0 to 1.3.1

19

CHANGELOG.md

@@ -6,2 +6,21 @@ # Change Log

## [1.3.0](https://github.com/daybrush/keycon/compare/keycon@1.2.2...keycon@1.3.0) (2022-09-24)
### :rocket: New Features
* add vue2 & vue3 keycon ([bac8a4d](https://github.com/daybrush/keycon/commit/bac8a4dbbb4aeb10a0ccb89a4a7858b7fb9b0ab5))
### :bug: Bug Fix
* fix commonjs config ([abbd4e3](https://github.com/daybrush/keycon/commit/abbd4e37dd7e9c70e9a870b636ccca5bd200f302))
### :mega: Other
* update packages versions ([94156a3](https://github.com/daybrush/keycon/commit/94156a3c54665c3ea4db2c3babcdaf8ad67bd3d9))
## [1.2.2](https://github.com/daybrush/keycon/compare/keycon@1.2.1...keycon@1.2.2) (2022-07-23)

@@ -8,0 +27,0 @@

23

dist/keycon.cjs.js

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

repository: git+https://github.com/daybrush/keycon.git
version: 1.3.0
version: 1.3.1
*/

@@ -944,3 +944,3 @@ 'use strict';

repository: https://github.com/naver/cfcs
version: 0.0.4
version: 0.0.6
*/

@@ -956,2 +956,5 @@

}
function isObject(val) {
return typeof val === "object";
}
function isFunction(val) {

@@ -1001,5 +1004,14 @@ return typeof val === "function";

}
function defineObservers(instance) {
var observers = {};
Object.defineProperty(instance, OBSERVERS_PATH, {
get: function () {
return observers;
}
});
return observers;
}
function getObservers(instance) {
if (!instance[OBSERVERS_PATH]) {
instance[OBSERVERS_PATH] = {};
defineObservers(instance);
}

@@ -1023,3 +1035,3 @@

function isObserver(val) {
return val && "current" in val && "subscribe" in val && "unsubscribe" in val;
return val && isObject(val) && "current" in val && "subscribe" in val && "unsubscribe" in val;
}

@@ -1075,2 +1087,3 @@

var reactiveObject = {};
defineObservers(reactiveObject);
keys(result).forEach(function (name) {

@@ -1099,3 +1112,3 @@ var value = result[name];

var keys = data.keys;
var keycon = new KeyController((_b = (_a = data.ref) === null || _a === void 0 ? void 0 : _a.current) !== null && _b !== void 0 ? _b : window);
var keycon = new KeyController(((_a = data.ref) === null || _a === void 0 ? void 0 : _a.current) || ((_b = data.ref) === null || _b === void 0 ? void 0 : _b.value) || window);
var isKeydown = observe(false);

@@ -1102,0 +1115,0 @@ keycon.keydown(keys, function () {

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

repository: git+https://github.com/daybrush/keycon.git
version: 1.3.0
version: 1.3.1
*/

@@ -942,3 +942,3 @@ import EventEmitter from '@scena/event-emitter';

repository: https://github.com/naver/cfcs
version: 0.0.4
version: 0.0.6
*/

@@ -954,2 +954,5 @@

}
function isObject(val) {
return typeof val === "object";
}
function isFunction(val) {

@@ -999,5 +1002,14 @@ return typeof val === "function";

}
function defineObservers(instance) {
var observers = {};
Object.defineProperty(instance, OBSERVERS_PATH, {
get: function () {
return observers;
}
});
return observers;
}
function getObservers(instance) {
if (!instance[OBSERVERS_PATH]) {
instance[OBSERVERS_PATH] = {};
defineObservers(instance);
}

@@ -1021,3 +1033,3 @@

function isObserver(val) {
return val && "current" in val && "subscribe" in val && "unsubscribe" in val;
return val && isObject(val) && "current" in val && "subscribe" in val && "unsubscribe" in val;
}

@@ -1073,2 +1085,3 @@

var reactiveObject = {};
defineObservers(reactiveObject);
keys(result).forEach(function (name) {

@@ -1097,3 +1110,3 @@ var value = result[name];

var keys = data.keys;
var keycon = new KeyController((_b = (_a = data.ref) === null || _a === void 0 ? void 0 : _a.current) !== null && _b !== void 0 ? _b : window);
var keycon = new KeyController(((_a = data.ref) === null || _a === void 0 ? void 0 : _a.current) || ((_b = data.ref) === null || _b === void 0 ? void 0 : _b.value) || window);
var isKeydown = observe(false);

@@ -1100,0 +1113,0 @@ keycon.keydown(keys, function () {

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

repository: git+https://github.com/daybrush/keycon.git
version: 1.3.0
version: 1.3.1
*/

@@ -1371,3 +1371,3 @@ (function (global, factory) {

repository: https://github.com/naver/cfcs
version: 0.0.4
version: 0.0.6
*/

@@ -1383,2 +1383,5 @@

}
function isObject$1(val) {
return typeof val === "object";
}
function isFunction(val) {

@@ -1428,5 +1431,14 @@ return typeof val === "function";

}
function defineObservers(instance) {
var observers = {};
Object.defineProperty(instance, OBSERVERS_PATH, {
get: function () {
return observers;
}
});
return observers;
}
function getObservers(instance) {
if (!instance[OBSERVERS_PATH]) {
instance[OBSERVERS_PATH] = {};
defineObservers(instance);
}

@@ -1450,3 +1462,3 @@

function isObserver(val) {
return val && "current" in val && "subscribe" in val && "unsubscribe" in val;
return val && isObject$1(val) && "current" in val && "subscribe" in val && "unsubscribe" in val;
}

@@ -1502,2 +1514,3 @@

var reactiveObject = {};
defineObservers(reactiveObject);
keys(result).forEach(function (name) {

@@ -1526,3 +1539,3 @@ var value = result[name];

var keys = data.keys;
var keycon = new KeyController((_b = (_a = data.ref) === null || _a === void 0 ? void 0 : _a.current) !== null && _b !== void 0 ? _b : window);
var keycon = new KeyController(((_a = data.ref) === null || _a === void 0 ? void 0 : _a.current) || ((_b = data.ref) === null || _b === void 0 ? void 0 : _b.value) || window);
var isKeydown = observe(false);

@@ -1529,0 +1542,0 @@ keycon.keydown(keys, function () {

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

repository: git+https://github.com/daybrush/keycon.git
version: 1.3.0
version: 1.3.1
*/
!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 i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function u(t){return t&&"object"==typeof t}function c(t){return Array.isArray(t)}function f(t){return"string"==typeof t}function s(t,e,n,r){t.addEventListener(e,n,r)}function a(t,e,n,r){t.removeEventListener(e,n,r)}var o=function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var t=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(u(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(u(t))for(var n in t)this.off(n);else{var r,o;e?(r=this._events[t])&&-1<(o=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,o=0;o<r;++o)if(e(t[o],o,t))return o;return n}(r,function(t){return t.listener===e}))&&r.splice(o,1):this._events[t]=[]}else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this,t=(void 0===n&&(n={}),this._events[e]);if(!e||!t)return!0;var o=!1;return n.eventType=e,n.stop=function(){o=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),o=0,e=0;e<n;e++)for(var i=arguments[e],u=0,c=i.length;u<c;u++,o++)r[o]=i[u];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!o},e.trigger=function(t,e){return this.emit(t,e=void 0===e?{}:e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(o({listener:e},n))},t}();(function(t,e){function n(t){if(!t||"object"!=typeof t||(e=t.which||t.keyCode||t.charCode)&&(t=e),"number"==typeof t)return c[t];var e=String(t),t=r[e.toLowerCase()];return t||((t=o[e.toLowerCase()])?t:1===e.length?e.charCodeAt(0):void 0)}n.isEventKey=function(t,e){if(t&&"object"==typeof t){t=t.which||t.keyCode||t.charCode;if(null!=t)if("string"==typeof e){var n=r[e.toLowerCase()];if(n)return n===t;if(n=o[e.toLowerCase()])return n===t}else if("number"==typeof e)return e===t;return!1}};for(var r=(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},o=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},i=97;i<123;i++)r[String.fromCharCode(i)]=i-32;for(var i=48;i<58;i++)r[i-48]=i;for(i=1;i<13;i++)r["f"+i]=i+111;for(i=0;i<10;i++)r["numpad "+i]=i+96;var u,c=e.names=e.title={};for(i in r)c[r[i]]=i;for(u in o)r[u]=o[u]})(e={exports:{}},e.exports);var l,e=e.exports,y=(e.code,e.codes,e.aliases,e.names),h=(e.title,{"+":"plus","left command":"meta","right command":"meta"}),n={shift:1,ctrl:2,alt:3,meta:4};function d(t,e){var n,r=(y[t]||e||"").toLowerCase();for(n in h)r=r.replace(n,h[n]);return r.replace(/\s/g,"")}function v(t,e){void 0===e&&(e=d(t.keyCode,t.key));t=r(t);return-1===t.indexOf(e)&&t.push(e),t.filter(Boolean)}function r(t){return[t.shiftKey&&"shift",t.ctrlKey&&"ctrl",t.altKey&&"alt",t.metaKey&&"meta"].filter(Boolean)}function p(t){t=t.slice();return t.sort(function(t,e){return(n[t]||5)-(n[e]||5)}),t}var b=function(n){var t=o,e=n;if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}function o(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")},s(t,"blur",e.blur),s(t,"keydown",e.keydownEvent),s(t,"keyup",e.keyupEvent),e}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r);e=o.prototype;return Object.defineProperty(o,"global",{get:function(){return l=l||new o},enumerable:!1,configurable:!0}),o.setGlobal=function(){return this.global},e.destroy=function(){var t=this.container;this.clear(),this.off(),a(t,"blur",this.blur),a(t,"keydown",this.keydownEvent),a(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 c(e)?this.on("".concat(t,".").concat(p(e).join(".")),n):f(e)?this.on("".concat(t,".").concat(e),n):this.on(t,e),this},e.removeEvent=function(t,e,n){return c(e)?this.off("".concat(t,".").concat(p(e).join(".")),n):f(e)?this.off("".concat(t,".").concat(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=d(e.keyCode,e.key),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},e=(this.trigger(t,r),this.trigger("".concat(t,".").concat(n),r),v(e,n));1<e.length&&this.trigger("".concat(t,".").concat(e.join(".")),r)},o}(t);function g(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||0<e--)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}(arguments[e]));return t}function k(t){return void 0===t}var w=function(){function t(t,e){var n,r;if(this._canceled=!1,e)try{for(var o=g(Object.keys(e)),i=o.next();!i.done;i=o.next()){var u=i.value;this[u]=e[u]}}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}this.eventType=t}var e=t.prototype;return e.stop=function(){this._canceled=!0},e.isCanceled=function(){return this._canceled},t}(),_=function(){function t(){this._eventHandler={}}var e=t.prototype;return e.trigger=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];var r=e instanceof w?e.eventType:e,r=m(this._eventHandler[r]||[]);return r.length<=0||(e instanceof w?(e.currentTarget=this,r.forEach(function(t){t(e)})):r.forEach(function(t){t.apply(void 0,m(n))})),this},e.once=function(n,r){var o,i=this;if("object"==typeof n&&k(r)){var t,e=n;for(t in e)this.once(t,e[t])}else"string"==typeof n&&"function"==typeof r&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.apply(void 0,m(t)),i.off(n,o)},this.on(n,o));return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&k(e)){var n,r=t;for(n in r)this.on(n,r[n])}else{var o;"string"==typeof t&&"function"==typeof e&&(o=this._eventHandler[t],k(o)&&(this._eventHandler[t]=[],o=this._eventHandler[t]),o.push(e))}return this},e.off=function(t,e){var n,r;if(k(t))return this._eventHandler={},this;if(k(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var o,i=t;for(o in i)this.off(o,i[o])}else{var u=this._eventHandler[t];if(u){var c=0;try{for(var f=g(u),s=f.next();!s.done;s=f.next()){if(s.value===e){u.splice(c,1),u.length<=0&&delete this._eventHandler[t];break}c++}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}}}return this},t.VERSION="3.0.2",t}();function K(t){return Object.keys(t)}var E="__observers__",j=function(){function t(t){this._emitter=new _,this._current=t}var e=t.prototype;return Object.defineProperty(e,"current",{get:function(){return this._current},set:function(t){var e=t!==this._current;this._current=t,e&&this._emitter.trigger("update",t)},enumerable:!1,configurable:!0}),e.subscribe=function(t){this._emitter.on("update",t)},e.unsubscribe=function(t){this._emitter.off("update",t)},t}();function C(t){return new j(t)}function O(t){return t[E]||(t[E]={}),t[E]}function x(t,e,n){t=O(t);return t[e]||(t[e]=C(n)),t[e]}function H(t){var i="function"==typeof t?t():t,u={};return K(i).forEach(function(t){var e,n,r,o=i[t];(r=o)&&"current"in r&&"subscribe"in r&&"unsubscribe"in r?(r=t,n=o,O(u)[r]=n,r=u,e=(n=t)||n,Object.defineProperty(r,n,{get:function(){return x(this,e).current},set:function(t){x(this,e,t).current=t}}),e!==n&&Object.defineProperty(r,e,{get:function(){return x(this,e).current}})):u[t]=o}),(t=u).subscribe=function(t,e){x(this,t).subscribe(e)},t.unsubscribe=function(t,e){var n=this;t?t in this&&x(this,t).unsubscribe(e):K(O(this)).forEach(function(t){n.unsubscribe(t)})},u}var S,T={__proto__:null,default:b,getKey:d,getCombi:v,getModifierCombi:r,REACTIVE:{events:["keydown","keyup","blur"],state:{isKeydown:!1},mounted:function(t){var e=t.keys,n=new b(null!=(t=null==(t=t.ref)?void 0:t.current)?t:window),r=C(!1);return n.keydown(e,function(){r.current=!0}),n.keyup(e,function(){r.current=!1}),n.on("blur",function(){r.current=!1}),H({inst:n,keys:e,destroy:function(){return n.destroy()},isKeydown:r})},destroy:function(t){t.destroy()},on:function(t,e,n){var r=t.inst;"keydown"===e?r.keydown(t.keys,n):"keyup"===e?r.keyup(t.keys,n):r.on(e,n)},off:function(t,e,n){var r=t.inst;"keydown"===e?r.offKeydown(t.keys,n):"keyup"===e?r.offKeyup(t.keys,n):r.off(e,n)}}};for(S in T)b[S]=T[S];return b});
!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 i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function u(t){return t&&"object"==typeof t}function c(t){return Array.isArray(t)}function f(t){return"string"==typeof t}function a(t,e,n,r){t.addEventListener(e,n,r)}function s(t,e,n,r){t.removeEventListener(e,n,r)}var o=function(){return(o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var t=function(){function t(){this._events={}}var e=t.prototype;return e.on=function(t,e){if(u(t))for(var n in t)this.on(n,t[n]);else this._addEvent(t,e,{});return this},e.off=function(t,e){if(t)if(u(t))for(var n in t)this.off(n);else{var r,o;e?(r=this._events[t])&&-1<(o=function(t,e,n){void 0===n&&(n=-1);for(var r=t.length,o=0;o<r;++o)if(e(t[o],o,t))return o;return n}(r,function(t){return t.listener===e}))&&r.splice(o,1):this._events[t]=[]}else this._events={};return this},e.once=function(e,t){var n=this;return t&&this._addEvent(e,t,{once:!0}),new Promise(function(t){n._addEvent(e,t,{once:!0})})},e.emit=function(e,n){var r=this,t=(void 0===n&&(n={}),this._events[e]);if(!e||!t)return!0;var o=!1;return n.eventType=e,n.stop=function(){o=!0},n.currentTarget=this,function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),o=0,e=0;e<n;e++)for(var i=arguments[e],u=0,c=i.length;u<c;u++,o++)r[o]=i[u];return r}(t).forEach(function(t){t.listener(n),t.once&&r.off(e,t.listener)}),!o},e.trigger=function(t,e){return this.emit(t,e=void 0===e?{}:e)},e._addEvent=function(t,e,n){var r=this._events;r[t]=r[t]||[],r[t].push(o({listener:e},n))},t}();(function(t,e){function n(t){if(!t||"object"!=typeof t||(e=t.which||t.keyCode||t.charCode)&&(t=e),"number"==typeof t)return c[t];var e=String(t),t=r[e.toLowerCase()];return t||((t=o[e.toLowerCase()])?t:1===e.length?e.charCodeAt(0):void 0)}n.isEventKey=function(t,e){if(t&&"object"==typeof t){t=t.which||t.keyCode||t.charCode;if(null!=t)if("string"==typeof e){var n=r[e.toLowerCase()];if(n)return n===t;if(n=o[e.toLowerCase()])return n===t}else if("number"==typeof e)return e===t;return!1}};for(var r=(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},o=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},i=97;i<123;i++)r[String.fromCharCode(i)]=i-32;for(var i=48;i<58;i++)r[i-48]=i;for(i=1;i<13;i++)r["f"+i]=i+111;for(i=0;i<10;i++)r["numpad "+i]=i+96;var u,c=e.names=e.title={};for(i in r)c[r[i]]=i;for(u in o)r[u]=o[u]})(e={exports:{}},e.exports);var l,e=e.exports,y=(e.code,e.codes,e.aliases,e.names),h=(e.title,{"+":"plus","left command":"meta","right command":"meta"}),n={shift:1,ctrl:2,alt:3,meta:4};function d(t,e){var n,r=(y[t]||e||"").toLowerCase();for(n in h)r=r.replace(n,h[n]);return r.replace(/\s/g,"")}function v(t,e){void 0===e&&(e=d(t.keyCode,t.key));t=r(t);return-1===t.indexOf(e)&&t.push(e),t.filter(Boolean)}function r(t){return[t.shiftKey&&"shift",t.ctrlKey&&"ctrl",t.altKey&&"alt",t.metaKey&&"meta"].filter(Boolean)}function p(t){t=t.slice();return t.sort(function(t,e){return(n[t]||5)-(n[e]||5)}),t}var b=function(n){var t=o,e=n;if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}function o(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")},a(t,"blur",e.blur),a(t,"keydown",e.keydownEvent),a(t,"keyup",e.keyupEvent),e}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r);e=o.prototype;return Object.defineProperty(o,"global",{get:function(){return l=l||new o},enumerable:!1,configurable:!0}),o.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 c(e)?this.on("".concat(t,".").concat(p(e).join(".")),n):f(e)?this.on("".concat(t,".").concat(e),n):this.on(t,e),this},e.removeEvent=function(t,e,n){return c(e)?this.off("".concat(t,".").concat(p(e).join(".")),n):f(e)?this.off("".concat(t,".").concat(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=d(e.keyCode,e.key),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},e=(this.trigger(t,r),this.trigger("".concat(t,".").concat(n),r),v(e,n));1<e.length&&this.trigger("".concat(t,".").concat(e.join(".")),r)},o}(t);function g(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||0<e--)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}(arguments[e]));return t}function k(t){return void 0===t}var w=function(){function t(t,e){var n,r;if(this._canceled=!1,e)try{for(var o=g(Object.keys(e)),i=o.next();!i.done;i=o.next()){var u=i.value;this[u]=e[u]}}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}this.eventType=t}var e=t.prototype;return e.stop=function(){this._canceled=!0},e.isCanceled=function(){return this._canceled},t}(),_=function(){function t(){this._eventHandler={}}var e=t.prototype;return e.trigger=function(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];var r=e instanceof w?e.eventType:e,r=m(this._eventHandler[r]||[]);return r.length<=0||(e instanceof w?(e.currentTarget=this,r.forEach(function(t){t(e)})):r.forEach(function(t){t.apply(void 0,m(n))})),this},e.once=function(n,r){var o,i=this;if("object"==typeof n&&k(r)){var t,e=n;for(t in e)this.once(t,e[t])}else"string"==typeof n&&"function"==typeof r&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.apply(void 0,m(t)),i.off(n,o)},this.on(n,o));return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&k(e)){var n,r=t;for(n in r)this.on(n,r[n])}else{var o;"string"==typeof t&&"function"==typeof e&&(o=this._eventHandler[t],k(o)&&(this._eventHandler[t]=[],o=this._eventHandler[t]),o.push(e))}return this},e.off=function(t,e){var n,r;if(k(t))return this._eventHandler={},this;if(k(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var o,i=t;for(o in i)this.off(o,i[o])}else{var u=this._eventHandler[t];if(u){var c=0;try{for(var f=g(u),a=f.next();!a.done;a=f.next()){if(a.value===e){u.splice(c,1),u.length<=0&&delete this._eventHandler[t];break}c++}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}}}return this},t.VERSION="3.0.2",t}();function K(t){return Object.keys(t)}var E="__observers__",j=function(){function t(t){this._emitter=new _,this._current=t}var e=t.prototype;return Object.defineProperty(e,"current",{get:function(){return this._current},set:function(t){var e=t!==this._current;this._current=t,e&&this._emitter.trigger("update",t)},enumerable:!1,configurable:!0}),e.subscribe=function(t){this._emitter.on("update",t)},e.unsubscribe=function(t){this._emitter.off("update",t)},t}();function C(t){return new j(t)}function O(t){var e={};Object.defineProperty(t,E,{get:function(){return e}})}function x(t){return t[E]||O(t),t[E]}function H(t,e,n){t=x(t);return t[e]||(t[e]=C(n)),t[e]}function P(t){var i="function"==typeof t?t():t,u={};return O(u),K(i).forEach(function(t){var e,n,r,o=i[t];(r=o)&&"object"==typeof r&&"current"in r&&"subscribe"in r&&"unsubscribe"in r?(r=t,n=o,x(u)[r]=n,r=u,e=(n=t)||n,Object.defineProperty(r,n,{get:function(){return H(this,e).current},set:function(t){H(this,e,t).current=t}}),e!==n&&Object.defineProperty(r,e,{get:function(){return H(this,e).current}})):u[t]=o}),(t=u).subscribe=function(t,e){H(this,t).subscribe(e)},t.unsubscribe=function(t,e){var n=this;t?t in this&&H(this,t).unsubscribe(e):K(x(this)).forEach(function(t){n.unsubscribe(t)})},u}var S,T={__proto__:null,default:b,getKey:d,getCombi:v,getModifierCombi:r,REACTIVE:{events:["keydown","keyup","blur"],state:{isKeydown:!1},mounted:function(t){var e,n=t.keys,r=new b((null==(e=t.ref)?void 0:e.current)||(null==(e=t.ref)?void 0:e.value)||window),o=C(!1);return r.keydown(n,function(){o.current=!0}),r.keyup(n,function(){o.current=!1}),r.on("blur",function(){o.current=!1}),P({inst:r,keys:n,destroy:function(){return r.destroy()},isKeydown:o})},destroy:function(t){t.destroy()},on:function(t,e,n){var r=t.inst;"keydown"===e?r.keydown(t.keys,n):"keyup"===e?r.keyup(t.keys,n):r.on(e,n)},off:function(t,e,n){var r=t.inst;"keydown"===e?r.offKeydown(t.keys,n):"keyup"===e?r.offKeyup(t.keys,n):r.off(e,n)}}};for(S in T)b[S]=T[S];return b});
//# sourceMappingURL=keycon.min.js.map
{
"name": "keycon",
"version": "1.3.0",
"version": "1.3.1",
"description": "Keyboard Controller",

@@ -38,3 +38,3 @@ "main": "./dist/keycon.cjs.js",

"@scena/event-emitter": "^1.0.2",
"@cfcs/core": "^0.0.4",
"@cfcs/core": "^0.0.6",
"keycode": "^2.2.0"

@@ -41,0 +41,0 @@ },

@@ -26,3 +26,3 @@ import { ReactiveAdapter, reactive, Ref, observe, ReactiveObject, Observer } from "@cfcs/core";

const keys = data.keys;
const keycon = new KeyController(data.ref?.current ?? window);
const keycon = new KeyController((data.ref?.current || data.ref?.value) || window);
const isKeydown = observe(false);

@@ -29,0 +29,0 @@

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