From bced4043e87aa4aa350a48eac7b34a5a1512bf37 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Sat, 9 Apr 2022 00:44:29 +0800 Subject: [PATCH] released v3.8.8 --- dist/hotkeys.common.js | 26 ++++++++++++++++---------- dist/hotkeys.common.min.js | 4 ++-- dist/hotkeys.esm.js | 26 ++++++++++++++++---------- dist/hotkeys.js | 26 ++++++++++++++++---------- dist/hotkeys.min.js | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 7 files changed, 55 insertions(+), 37 deletions(-) diff --git a/dist/hotkeys.common.js b/dist/hotkeys.common.js index 5eb4e33..9ed093e 100644 --- a/dist/hotkeys.common.js +++ b/dist/hotkeys.common.js @@ -1,11 +1,10 @@ -/*! - * hotkeys-js v3.8.7 - * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. +/**! + * hotkeys-js v3.8.8 + * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. * - * Copyright (c) 2022 kenny wong - * http://jaywcjlove.github.io/hotkeys - * - * Licensed under the MIT license. + * Copyright (c) 2022 kenny wong + * http://jaywcjlove.github.io/hotkeys + * Licensed under the MIT license */ 'use strict'; @@ -157,6 +156,8 @@ for (var k = 1; k < 20; k++) { var _downKeys = []; // 记录摁下的绑定键 +var winListendFocus = false; // window是否已经监听了focus事件 + var _scope = 'all'; // 默认热键范围 var elementHasBindEvent = []; // 已绑定事件的节点记录 @@ -526,9 +527,14 @@ function hotkeys(key, option, method) { addEvent(element, 'keydown', function (e) { dispatch(e); }); - addEvent(window, 'focus', function () { - _downKeys = []; - }); + + if (!winListendFocus) { + winListendFocus = true; + addEvent(window, 'focus', function () { + _downKeys = []; + }); + } + addEvent(element, 'keyup', function (e) { dispatch(e); clearModifier(e); diff --git a/dist/hotkeys.common.min.js b/dist/hotkeys.common.min.js index c6e9e29..4f36987 100644 --- a/dist/hotkeys.common.min.js +++ b/dist/hotkeys.common.min.js @@ -1,2 +1,2 @@ -/*! hotkeys-js v3.8.7 | MIT (c) 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 - * http://jaywcjlove.github.io/hotkeys - * - * Licensed under the MIT license. + * Copyright (c) 2022 kenny wong + * http://jaywcjlove.github.io/hotkeys + * Licensed under the MIT license */ var isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; // 绑定事件 @@ -155,6 +154,8 @@ for (var k = 1; k < 20; k++) { var _downKeys = []; // 记录摁下的绑定键 +var winListendFocus = false; // window是否已经监听了focus事件 + var _scope = 'all'; // 默认热键范围 var elementHasBindEvent = []; // 已绑定事件的节点记录 @@ -524,9 +525,14 @@ function hotkeys(key, option, method) { addEvent(element, 'keydown', function (e) { dispatch(e); }); - addEvent(window, 'focus', function () { - _downKeys = []; - }); + + if (!winListendFocus) { + winListendFocus = true; + addEvent(window, 'focus', function () { + _downKeys = []; + }); + } + addEvent(element, 'keyup', function (e) { dispatch(e); clearModifier(e); diff --git a/dist/hotkeys.js b/dist/hotkeys.js index 5d43f43..82334b3 100644 --- a/dist/hotkeys.js +++ b/dist/hotkeys.js @@ -1,11 +1,10 @@ -/*! - * hotkeys-js v3.8.7 - * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. +/**! + * hotkeys-js v3.8.8 + * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. * - * Copyright (c) 2022 kenny wong - * http://jaywcjlove.github.io/hotkeys - * - * Licensed under the MIT license. + * Copyright (c) 2022 kenny wong + * http://jaywcjlove.github.io/hotkeys + * Licensed under the MIT license */ (function (global, factory) { @@ -161,6 +160,8 @@ var _downKeys = []; // 记录摁下的绑定键 + var winListendFocus = false; // window是否已经监听了focus事件 + var _scope = 'all'; // 默认热键范围 var elementHasBindEvent = []; // 已绑定事件的节点记录 @@ -530,9 +531,14 @@ addEvent(element, 'keydown', function (e) { dispatch(e); }); - addEvent(window, 'focus', function () { - _downKeys = []; - }); + + if (!winListendFocus) { + winListendFocus = true; + addEvent(window, 'focus', function () { + _downKeys = []; + }); + } + addEvent(element, 'keyup', function (e) { dispatch(e); clearModifier(e); diff --git a/dist/hotkeys.min.js b/dist/hotkeys.min.js index 507448e..a61a988 100644 --- a/dist/hotkeys.min.js +++ b/dist/hotkeys.min.js @@ -1,2 +1,2 @@ -/*! hotkeys-js v3.8.7 | MIT (c) 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