diff --git a/dist/hotkeys.common.js b/dist/hotkeys.common.js index e762e0aa..67d40e9e 100644 --- a/dist/hotkeys.common.js +++ b/dist/hotkeys.common.js @@ -1,8 +1,8 @@ /**! - * hotkeys-js v3.10.1 + * hotkeys-js v3.10.2 * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. * - * Copyright (c) 2022 kenny wong + * Copyright (c) 2023 kenny wong * http://jaywcjlove.github.io/hotkeys * Licensed under the MIT license */ @@ -464,7 +464,7 @@ function dispatch(event, element) { for (var _i = 0; _i < _handlers[key].length; _i++) { if (event.type === 'keydown' && _handlers[key][_i].keydown || event.type === 'keyup' && _handlers[key][_i].keyup) { - if (_handlers[key][_i].key) { + if (_handlers[key][_i].key && _handlers[key][_i].scope === scope) { var record = _handlers[key][_i]; var splitKey = record.splitKey; var keyShortcut = record.key.split(splitKey); @@ -474,7 +474,7 @@ function dispatch(event, element) { _downKeysCurrent.push(code(keyShortcut[a])); } - if (_downKeysCurrent.sort().join('') === _downKeys.sort().join('')) { + if (_downKeysCurrent.sort().join('') === _downKeys.slice().sort().join('')) { // 找到处理内容 eventHandler(event, record, scope, element); } diff --git a/dist/hotkeys.common.min.js b/dist/hotkeys.common.min.js index acc44952..89ca2bec 100644 --- a/dist/hotkeys.common.min.js +++ b/dist/hotkeys.common.min.js @@ -1,2 +1,2 @@ -/*! hotkeys-js v3.10.1 | MIT © 2022 kenny wong http://jaywcjlove.github.io/hotkeys */ -"use strict";var isff="undefined"!=typeof navigator&&0 http://jaywcjlove.github.io/hotkeys */ +"use strict";var isff="undefined"!=typeof navigator&&0 + * Copyright (c) 2023 kenny wong * http://jaywcjlove.github.io/hotkeys * Licensed under the MIT license */ @@ -462,7 +462,7 @@ function dispatch(event, element) { for (var _i = 0; _i < _handlers[key].length; _i++) { if (event.type === 'keydown' && _handlers[key][_i].keydown || event.type === 'keyup' && _handlers[key][_i].keyup) { - if (_handlers[key][_i].key) { + if (_handlers[key][_i].key && _handlers[key][_i].scope === scope) { var record = _handlers[key][_i]; var splitKey = record.splitKey; var keyShortcut = record.key.split(splitKey); @@ -472,7 +472,7 @@ function dispatch(event, element) { _downKeysCurrent.push(code(keyShortcut[a])); } - if (_downKeysCurrent.sort().join('') === _downKeys.sort().join('')) { + if (_downKeysCurrent.sort().join('') === _downKeys.slice().sort().join('')) { // 找到处理内容 eventHandler(event, record, scope, element); } diff --git a/dist/hotkeys.js b/dist/hotkeys.js index 82f6e05a..6b589fc8 100644 --- a/dist/hotkeys.js +++ b/dist/hotkeys.js @@ -1,8 +1,8 @@ /**! - * hotkeys-js v3.10.1 + * hotkeys-js v3.10.2 * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. * - * Copyright (c) 2022 kenny wong + * Copyright (c) 2023 kenny wong * http://jaywcjlove.github.io/hotkeys * Licensed under the MIT license */ @@ -468,7 +468,7 @@ for (var _i = 0; _i < _handlers[key].length; _i++) { if (event.type === 'keydown' && _handlers[key][_i].keydown || event.type === 'keyup' && _handlers[key][_i].keyup) { - if (_handlers[key][_i].key) { + if (_handlers[key][_i].key && _handlers[key][_i].scope === scope) { var record = _handlers[key][_i]; var splitKey = record.splitKey; var keyShortcut = record.key.split(splitKey); @@ -478,7 +478,7 @@ _downKeysCurrent.push(code(keyShortcut[a])); } - if (_downKeysCurrent.sort().join('') === _downKeys.sort().join('')) { + if (_downKeysCurrent.sort().join('') === _downKeys.slice().sort().join('')) { // 找到处理内容 eventHandler(event, record, scope, element); } diff --git a/dist/hotkeys.min.js b/dist/hotkeys.min.js index 67963ab2..3ffb35c1 100644 --- a/dist/hotkeys.min.js +++ b/dist/hotkeys.min.js @@ -1,2 +1,2 @@ -/*! hotkeys-js v3.10.1 | MIT © 2022 kenny wong http://jaywcjlove.github.io/hotkeys */ -!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 http://jaywcjlove.github.io/hotkeys */ +!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 { expect(e.metaKey).toBeTruthy(); expect(e.ctrlKey).toBeTruthy(); expect(e.shiftKey).toBeTruthy(); - expect(hotkeys.getPressedKeyCodes()).toEqual([16, 17, 65, 91]); + expect(hotkeys.getPressedKeyCodes()).toEqual([65, 17, 16, 91]); }); __triggerKeyboardEvent(document.body, 65, { metaKey: true, @@ -114,7 +114,7 @@ describe('\n Hotkeys.js Test Case222.\n', () => { expect(e.metaKey).toBeTruthy(); expect(e.ctrlKey).toBeTruthy(); expect(e.shiftKey).toBeTruthy(); - expect(hotkeys.getPressedKeyString()).toEqual(['⇧', '⌃', 'A', '⌘']); + expect(hotkeys.getPressedKeyString()).toEqual(['A', '⌃', '⇧', '⌘']); }); __triggerKeyboardEvent(document.body, 65, { metaKey: true, @@ -180,7 +180,7 @@ describe('\n Hotkeys.js Test Case222.\n', () => { await hotkeys('ctrl-a', { splitKey: '-' }, (e) => { isExecuteFunction = true; expect(e.ctrlKey).toBeTruthy(); - expect(hotkeys.getPressedKeyCodes()).toEqual([17, 65]); + expect(hotkeys.getPressedKeyCodes()).toEqual([65, 17]); }); __triggerKeyboardEvent(document.body, 65, { ctrlKey: true,