diff --git a/dist/hotkeys.common.js b/dist/hotkeys.common.js index d9bdbbe..80c7513 100644 --- a/dist/hotkeys.common.js +++ b/dist/hotkeys.common.js @@ -9,6 +9,32 @@ 'use strict'; +function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); +} +function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); +} +function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); +} +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; +} +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + var isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; // 绑定事件 @@ -189,6 +215,23 @@ function getPressedKeyString() { return getKey(c) || getModifier(c) || String.fromCharCode(c); }); } +function getAllKeyCodes() { + var _ref; + return (_ref = []).concat.apply(_ref, _toConsumableArray(Object.values(_handlers))).map(function (_ref2) { + var key = _ref2.key, + scope = _ref2.scope, + mods = _ref2.mods, + shortcut = _ref2.shortcut; + return { + scope: scope, + shortcut: shortcut, + mods: mods, + keys: key.split('+').map(function (k) { + return code(k); + }) + }; + }); +} // 表单控件控件判断 返回 Boolean // hotkey is effective only when filter return true @@ -291,12 +334,12 @@ function unbind(keysInfo) { } // 解除绑定某个范围的快捷键 -var eachUnbind = function eachUnbind(_ref) { - var key = _ref.key, - scope = _ref.scope, - method = _ref.method, - _ref$splitKey = _ref.splitKey, - splitKey = _ref$splitKey === void 0 ? '+' : _ref$splitKey; +var eachUnbind = function eachUnbind(_ref3) { + var key = _ref3.key, + scope = _ref3.scope, + method = _ref3.method, + _ref3$splitKey = _ref3.splitKey, + splitKey = _ref3$splitKey === void 0 ? '+' : _ref3$splitKey; var multipleKeys = getKeys(key); multipleKeys.forEach(function (originKey) { var unbindKeys = originKey.split(splitKey); @@ -548,6 +591,7 @@ var _api = { getScope: getScope, deleteScope: deleteScope, getPressedKeyCodes: getPressedKeyCodes, + getAllKeyCodes: getAllKeyCodes, isPressed: isPressed, filter: filter, trigger: trigger, diff --git a/dist/hotkeys.common.min.js b/dist/hotkeys.common.min.js index 2337d9f..650e71a 100644 --- a/dist/hotkeys.common.min.js +++ b/dist/hotkeys.common.min.js @@ -1,2 +1,2 @@ /*! hotkeys-js v3.11.2 | MIT © 2023 kenny wong https://jaywcjlove.github.io/hotkeys-js */ -"use strict";var isff="undefined"!=typeof navigator&&0 arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; +} +function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} + var isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; // 绑定事件 @@ -187,6 +213,23 @@ function getPressedKeyString() { return getKey(c) || getModifier(c) || String.fromCharCode(c); }); } +function getAllKeyCodes() { + var _ref; + return (_ref = []).concat.apply(_ref, _toConsumableArray(Object.values(_handlers))).map(function (_ref2) { + var key = _ref2.key, + scope = _ref2.scope, + mods = _ref2.mods, + shortcut = _ref2.shortcut; + return { + scope: scope, + shortcut: shortcut, + mods: mods, + keys: key.split('+').map(function (k) { + return code(k); + }) + }; + }); +} // 表单控件控件判断 返回 Boolean // hotkey is effective only when filter return true @@ -289,12 +332,12 @@ function unbind(keysInfo) { } // 解除绑定某个范围的快捷键 -var eachUnbind = function eachUnbind(_ref) { - var key = _ref.key, - scope = _ref.scope, - method = _ref.method, - _ref$splitKey = _ref.splitKey, - splitKey = _ref$splitKey === void 0 ? '+' : _ref$splitKey; +var eachUnbind = function eachUnbind(_ref3) { + var key = _ref3.key, + scope = _ref3.scope, + method = _ref3.method, + _ref3$splitKey = _ref3.splitKey, + splitKey = _ref3$splitKey === void 0 ? '+' : _ref3$splitKey; var multipleKeys = getKeys(key); multipleKeys.forEach(function (originKey) { var unbindKeys = originKey.split(splitKey); @@ -546,6 +589,7 @@ var _api = { getScope: getScope, deleteScope: deleteScope, getPressedKeyCodes: getPressedKeyCodes, + getAllKeyCodes: getAllKeyCodes, isPressed: isPressed, filter: filter, trigger: trigger, diff --git a/dist/hotkeys.js b/dist/hotkeys.js index 5b8c153..9790b82 100644 --- a/dist/hotkeys.js +++ b/dist/hotkeys.js @@ -13,6 +13,32 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.hotkeys = factory()); })(this, (function () { 'use strict'; + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); + } + function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); + } + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; + } + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + var isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; // 绑定事件 @@ -193,6 +219,23 @@ return getKey(c) || getModifier(c) || String.fromCharCode(c); }); } + function getAllKeyCodes() { + var _ref; + return (_ref = []).concat.apply(_ref, _toConsumableArray(Object.values(_handlers))).map(function (_ref2) { + var key = _ref2.key, + scope = _ref2.scope, + mods = _ref2.mods, + shortcut = _ref2.shortcut; + return { + scope: scope, + shortcut: shortcut, + mods: mods, + keys: key.split('+').map(function (k) { + return code(k); + }) + }; + }); + } // 表单控件控件判断 返回 Boolean // hotkey is effective only when filter return true @@ -295,12 +338,12 @@ } // 解除绑定某个范围的快捷键 - var eachUnbind = function eachUnbind(_ref) { - var key = _ref.key, - scope = _ref.scope, - method = _ref.method, - _ref$splitKey = _ref.splitKey, - splitKey = _ref$splitKey === void 0 ? '+' : _ref$splitKey; + var eachUnbind = function eachUnbind(_ref3) { + var key = _ref3.key, + scope = _ref3.scope, + method = _ref3.method, + _ref3$splitKey = _ref3.splitKey, + splitKey = _ref3$splitKey === void 0 ? '+' : _ref3$splitKey; var multipleKeys = getKeys(key); multipleKeys.forEach(function (originKey) { var unbindKeys = originKey.split(splitKey); @@ -552,6 +595,7 @@ getScope: getScope, deleteScope: deleteScope, getPressedKeyCodes: getPressedKeyCodes, + getAllKeyCodes: getAllKeyCodes, isPressed: isPressed, filter: filter, trigger: trigger, diff --git a/dist/hotkeys.min.js b/dist/hotkeys.min.js index 4867eb3..d830a31 100644 --- a/dist/hotkeys.min.js +++ b/dist/hotkeys.min.js @@ -1,2 +1,2 @@ /*! hotkeys-js v3.11.2 | MIT © 2023 kenny wong https://jaywcjlove.github.io/hotkeys-js */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).hotkeys=t()}(this,function(){"use strict";var e="undefined"!=typeof navigator&&0; modifierMap: Record; + getAllKeyCodes(): Omit; + setScope(scopeName: string): void; getScope(): string; deleteScope(scopeName: string, newScopeName?: string): void;