|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import { addEvent, getMods, getKeys, compareArray } from './utils';
|
|
|
|
|
import { _keyMap, _modifier, _downKeys, modifierMap, _mods, _handlers } from './var';
|
|
|
|
|
import { _keyMap, _modifier, modifierMap, _mods, _handlers } from './var';
|
|
|
|
|
|
|
|
|
|
let _downKeys = []; // 记录摁下的绑定键
|
|
|
|
|
|
|
|
|
|
let _scope = 'all'; // 默认热键范围
|
|
|
|
|
const elementHasBindEvent = []; // 已绑定事件的节点记录
|
|
|
|
@ -296,11 +297,14 @@ function hotkeys(key, option, method) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// 在全局document上设置快捷键
|
|
|
|
|
if (typeof element !== 'undefined' && !isElementBind(element)) {
|
|
|
|
|
if (typeof element !== 'undefined' && !isElementBind(element) && window) {
|
|
|
|
|
elementHasBindEvent.push(element);
|
|
|
|
|
addEvent(element, 'keydown', (e) => {
|
|
|
|
|
dispatch(e);
|
|
|
|
|
});
|
|
|
|
|
addEvent(window, 'focus', () => {
|
|
|
|
|
_downKeys = [];
|
|
|
|
|
});
|
|
|
|
|
addEvent(element, 'keyup', (e) => {
|
|
|
|
|
dispatch(e);
|
|
|
|
|
clearModifier(e);
|
|
|
|
|