From 335d00f30ccfef5644aa884d2b93d6364177ef5f Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Mon, 11 Apr 2022 20:15:57 +0800 Subject: [PATCH] released v3.8.9 (#352) --- dist/hotkeys.common.js | 21 +++++++++++++-------- dist/hotkeys.common.min.js | 4 ++-- dist/hotkeys.esm.js | 21 +++++++++++++-------- dist/hotkeys.js | 21 +++++++++++++-------- dist/hotkeys.min.js | 4 ++-- package.json | 2 +- 6 files changed, 44 insertions(+), 29 deletions(-) diff --git a/dist/hotkeys.common.js b/dist/hotkeys.common.js index 9ed093ea..2fca0bb0 100644 --- a/dist/hotkeys.common.js +++ b/dist/hotkeys.common.js @@ -1,5 +1,5 @@ /**! - * hotkeys-js v3.8.8 + * hotkeys-js v3.8.9 * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. * * Copyright (c) 2022 kenny wong @@ -318,7 +318,11 @@ var eachUnbind = function eachUnbind(_ref) { }; // 对监听对应快捷键的回调函数进行处理 -function eventHandler(event, handler, scope) { +function eventHandler(event, handler, scope, element) { + if (handler.element !== element) { + return; + } + var modifiersMatch; // 看它是否在当前范围 if (handler.scope === scope || handler.scope === 'all') { @@ -345,7 +349,7 @@ function eventHandler(event, handler, scope) { } // 处理keydown事件 -function dispatch(event) { +function dispatch(event, element) { var asterisk = _handlers['*']; var key = event.keyCode || event.which || event.charCode; // 表单控件过滤 默认表单控件不触发快捷键 @@ -430,7 +434,7 @@ function dispatch(event) { if (asterisk) { for (var i = 0; i < asterisk.length; i++) { if (asterisk[i].scope === scope && (event.type === 'keydown' && asterisk[i].keydown || event.type === 'keyup' && asterisk[i].keyup)) { - eventHandler(event, asterisk[i], scope); + eventHandler(event, asterisk[i], scope, element); } } } // key 不在 _handlers 中返回 @@ -452,7 +456,7 @@ function dispatch(event) { if (_downKeysCurrent.sort().join('') === _downKeys.sort().join('')) { // 找到处理内容 - eventHandler(event, record, scope); + eventHandler(event, record, scope, element); } } } @@ -517,7 +521,8 @@ function hotkeys(key, option, method) { shortcut: keys[i], method: method, key: keys[i], - splitKey: splitKey + splitKey: splitKey, + element: element }); } // 在全局document上设置快捷键 @@ -525,7 +530,7 @@ function hotkeys(key, option, method) { if (typeof element !== 'undefined' && !isElementBind(element) && window) { elementHasBindEvent.push(element); addEvent(element, 'keydown', function (e) { - dispatch(e); + dispatch(e, element); }); if (!winListendFocus) { @@ -536,7 +541,7 @@ function hotkeys(key, option, method) { } addEvent(element, 'keyup', function (e) { - dispatch(e); + dispatch(e, element); clearModifier(e); }); } diff --git a/dist/hotkeys.common.min.js b/dist/hotkeys.common.min.js index 4f36987d..b14c3cf6 100644 --- a/dist/hotkeys.common.min.js +++ b/dist/hotkeys.common.min.js @@ -1,2 +1,2 @@ -/*! hotkeys-js v3.8.8 | 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 @@ -316,7 +316,11 @@ var eachUnbind = function eachUnbind(_ref) { }; // 对监听对应快捷键的回调函数进行处理 -function eventHandler(event, handler, scope) { +function eventHandler(event, handler, scope, element) { + if (handler.element !== element) { + return; + } + var modifiersMatch; // 看它是否在当前范围 if (handler.scope === scope || handler.scope === 'all') { @@ -343,7 +347,7 @@ function eventHandler(event, handler, scope) { } // 处理keydown事件 -function dispatch(event) { +function dispatch(event, element) { var asterisk = _handlers['*']; var key = event.keyCode || event.which || event.charCode; // 表单控件过滤 默认表单控件不触发快捷键 @@ -428,7 +432,7 @@ function dispatch(event) { if (asterisk) { for (var i = 0; i < asterisk.length; i++) { if (asterisk[i].scope === scope && (event.type === 'keydown' && asterisk[i].keydown || event.type === 'keyup' && asterisk[i].keyup)) { - eventHandler(event, asterisk[i], scope); + eventHandler(event, asterisk[i], scope, element); } } } // key 不在 _handlers 中返回 @@ -450,7 +454,7 @@ function dispatch(event) { if (_downKeysCurrent.sort().join('') === _downKeys.sort().join('')) { // 找到处理内容 - eventHandler(event, record, scope); + eventHandler(event, record, scope, element); } } } @@ -515,7 +519,8 @@ function hotkeys(key, option, method) { shortcut: keys[i], method: method, key: keys[i], - splitKey: splitKey + splitKey: splitKey, + element: element }); } // 在全局document上设置快捷键 @@ -523,7 +528,7 @@ function hotkeys(key, option, method) { if (typeof element !== 'undefined' && !isElementBind(element) && window) { elementHasBindEvent.push(element); addEvent(element, 'keydown', function (e) { - dispatch(e); + dispatch(e, element); }); if (!winListendFocus) { @@ -534,7 +539,7 @@ function hotkeys(key, option, method) { } addEvent(element, 'keyup', function (e) { - dispatch(e); + dispatch(e, element); clearModifier(e); }); } diff --git a/dist/hotkeys.js b/dist/hotkeys.js index 82334b32..a73f62e5 100644 --- a/dist/hotkeys.js +++ b/dist/hotkeys.js @@ -1,5 +1,5 @@ /**! - * hotkeys-js v3.8.8 + * hotkeys-js v3.8.9 * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. * * Copyright (c) 2022 kenny wong @@ -322,7 +322,11 @@ }; // 对监听对应快捷键的回调函数进行处理 - function eventHandler(event, handler, scope) { + function eventHandler(event, handler, scope, element) { + if (handler.element !== element) { + return; + } + var modifiersMatch; // 看它是否在当前范围 if (handler.scope === scope || handler.scope === 'all') { @@ -349,7 +353,7 @@ } // 处理keydown事件 - function dispatch(event) { + function dispatch(event, element) { var asterisk = _handlers['*']; var key = event.keyCode || event.which || event.charCode; // 表单控件过滤 默认表单控件不触发快捷键 @@ -434,7 +438,7 @@ if (asterisk) { for (var i = 0; i < asterisk.length; i++) { if (asterisk[i].scope === scope && (event.type === 'keydown' && asterisk[i].keydown || event.type === 'keyup' && asterisk[i].keyup)) { - eventHandler(event, asterisk[i], scope); + eventHandler(event, asterisk[i], scope, element); } } } // key 不在 _handlers 中返回 @@ -456,7 +460,7 @@ if (_downKeysCurrent.sort().join('') === _downKeys.sort().join('')) { // 找到处理内容 - eventHandler(event, record, scope); + eventHandler(event, record, scope, element); } } } @@ -521,7 +525,8 @@ shortcut: keys[i], method: method, key: keys[i], - splitKey: splitKey + splitKey: splitKey, + element: element }); } // 在全局document上设置快捷键 @@ -529,7 +534,7 @@ if (typeof element !== 'undefined' && !isElementBind(element) && window) { elementHasBindEvent.push(element); addEvent(element, 'keydown', function (e) { - dispatch(e); + dispatch(e, element); }); if (!winListendFocus) { @@ -540,7 +545,7 @@ } addEvent(element, 'keyup', function (e) { - dispatch(e); + dispatch(e, element); clearModifier(e); }); } diff --git a/dist/hotkeys.min.js b/dist/hotkeys.min.js index a61a988c..fee53f22 100644 --- a/dist/hotkeys.min.js +++ b/dist/hotkeys.min.js @@ -1,2 +1,2 @@ -/*! hotkeys-js v3.8.8 | 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