From 7a73ae1322ef2d24c75e33c52605776eba9e3863 Mon Sep 17 00:00:00 2001 From: Jordan GAZEAU Date: Mon, 6 Feb 2023 23:53:11 +0100 Subject: [PATCH] fix: keyboard shortcuts --- assets/js/theme/init.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/assets/js/theme/init.js b/assets/js/theme/init.js index 40e01172..ddc96c72 100644 --- a/assets/js/theme/init.js +++ b/assets/js/theme/init.js @@ -1,3 +1,4 @@ +import { resizeFunctionsList, shortcutsKeys } from './modules/const.min.js'; import { addElementToModal, closeModals, @@ -5,13 +6,15 @@ import { getFirstAncestorByClass, isPreCopyToEnable, } from './modules/helpers.min.js'; -import { resizeFunctionsList, shortcutsKeys } from './modules/const.min.js'; // VARS // // MAIN // document.addEventListener('DOMContentLoaded', function () { // Manage shortcuts let keyBuffer = []; + window.addEventListener('blur', () => { + keyBuffer = []; + }); document.addEventListener('keyup', function (e) { const keyIndex = keyBuffer.indexOf(e.key); if (keyIndex > -1) { @@ -39,6 +42,7 @@ document.addEventListener('DOMContentLoaded', function () { ) { e.preventDefault(); window[shortcutsKeys[shortcut].function](); + keyBuffer = []; } } }