actual/patches/hotkeys-js+3.8.2.patch

95 lines
3.1 KiB
Diff
Raw Permalink Normal View History

2022-04-29 02:44:38 +00:00
diff --git a/node_modules/hotkeys-js/dist/hotkeys.common.js b/node_modules/hotkeys-js/dist/hotkeys.common.js
index bc18534..34c0d7d 100644
--- a/node_modules/hotkeys-js/dist/hotkeys.common.js
+++ b/node_modules/hotkeys-js/dist/hotkeys.common.js
@@ -22,7 +22,6 @@ function addEvent(object, event, method) {
}
} // 修饰键转换成对应的键码
-
function getMods(modifier, key) {
var mods = key.slice(0, key.length - 1);
@@ -33,7 +32,6 @@ function getMods(modifier, key) {
return mods;
} // 处理传的key字符串转换成数组
-
function getKeys(key) {
if (typeof key !== 'string') key = '';
key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等
diff --git a/node_modules/hotkeys-js/dist/hotkeys.esm.js b/node_modules/hotkeys-js/dist/hotkeys.esm.js
index 90295a5..f998483 100644
--- a/node_modules/hotkeys-js/dist/hotkeys.esm.js
+++ b/node_modules/hotkeys-js/dist/hotkeys.esm.js
@@ -9,6 +9,8 @@
*/
var isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; // 绑定事件
+var ismac =
+ navigator.platform && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
function addEvent(object, event, method) {
if (object.addEventListener) {
@@ -20,12 +22,20 @@ function addEvent(object, event, method) {
}
} // 修饰键转换成对应的键码
-
function getMods(modifier, key) {
var mods = key.slice(0, key.length - 1);
for (var i = 0; i < mods.length; i++) {
- mods[i] = modifier[mods[i].toLowerCase()];
+ let mod = mods[i].toLowerCase();
+ if(mod === 'mod') {
+ if(ismac) {
+ mod = 'cmd';
+ }
+ else {
+ mod = 'ctrl';
+ }
+ }
+ mods[i] = modifier[mod];
}
return mods;
@@ -145,6 +155,9 @@ var elementHasBindEvent = []; // 已绑定事件的节点记录
// 返回键码
var code = function code(x) {
+ if(x === 'mod') {
+ x = ismac ? 'cmd' : 'ctrl'
+ }
return _keyMap[x.toLowerCase()] || _modifier[x.toLowerCase()] || x.toUpperCase().charCodeAt(0);
}; // 设置获取当前范围(默认为'所有'
@@ -319,7 +332,6 @@ function eventHandler(event, handler, scope) {
}
} // 调用处理程序,如果是修饰键不做处理
-
if (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91] || modifiersMatch || handler.shortcut === '*') {
if (handler.method(event, handler) === false) {
if (event.preventDefault) event.preventDefault();else event.returnValue = false;
diff --git a/node_modules/hotkeys-js/dist/hotkeys.js b/node_modules/hotkeys-js/dist/hotkeys.js
index 15480e8..d203a42 100644
--- a/node_modules/hotkeys-js/dist/hotkeys.js
+++ b/node_modules/hotkeys-js/dist/hotkeys.js
@@ -26,7 +26,6 @@
}
} // 修饰键转换成对应的键码
-
function getMods(modifier, key) {
var mods = key.slice(0, key.length - 1);
@@ -37,7 +36,6 @@
return mods;
} // 处理传的key字符串转换成数组
-
function getKeys(key) {
if (typeof key !== 'string') key = '';
key = key.replace(/\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等