-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
973e607
commit 335d00f
Showing
6 changed files
with
44 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
|
@@ -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,15 +521,16 @@ function hotkeys(key, option, method) { | |
shortcut: keys[i], | ||
method: method, | ||
key: keys[i], | ||
splitKey: splitKey | ||
splitKey: splitKey, | ||
element: element | ||
}); | ||
} // 在全局document上设置快捷键 | ||
|
||
|
||
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); | ||
}); | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
|
@@ -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,15 +519,16 @@ function hotkeys(key, option, method) { | |
shortcut: keys[i], | ||
method: method, | ||
key: keys[i], | ||
splitKey: splitKey | ||
splitKey: splitKey, | ||
element: element | ||
}); | ||
} // 在全局document上设置快捷键 | ||
|
||
|
||
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); | ||
}); | ||
} | ||
|
Oops, something went wrong.
335d00f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.