From 1ac2c5b61ed181590182e2969fcbece1d9d5e29c Mon Sep 17 00:00:00 2001 From: Gabe Yuan Date: Sat, 9 Sep 2023 17:15:13 +0800 Subject: [PATCH] fix shortcut --- src/libs/shortcut.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/shortcut.js b/src/libs/shortcut.js index cf54a29..c0803f3 100644 --- a/src/libs/shortcut.js +++ b/src/libs/shortcut.js @@ -39,6 +39,10 @@ export const shortcutListener = (fn, target = document, timeout = 3000) => { target.addEventListener("keydown", handleKeydown); target.addEventListener("keyup", handleKeyup); return () => { + if (timer) { + clearTimeout(timer); + timer = null; + } target.removeEventListener("keydown", handleKeydown); target.removeEventListener("keyup", handleKeyup); };