From 91f14bc6f36b2c938bb230bc9c2d0388d4f838fa Mon Sep 17 00:00:00 2001 From: Weng Yuxuan Date: Sun, 25 Jun 2023 16:30:56 +0800 Subject: [PATCH] fix: downkeys order error in multi listeners --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 0f716898..7e2e1f3d 100644 --- a/src/index.js +++ b/src/index.js @@ -300,7 +300,7 @@ function dispatch(event, element) { (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) { const record = _handlers[key][i]; const { splitKey } = record; const keyShortcut = record.key.split(splitKey); @@ -308,7 +308,7 @@ function dispatch(event, element) { for (let a = 0; a < keyShortcut.length; a++) { _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); }