From 0127fddd116d26fa887af42354989838468baaf7 Mon Sep 17 00:00:00 2001 From: Marvin Scham <67930021+marvinscham@users.noreply.github.com> Date: Sun, 5 Jun 2022 19:57:06 +0200 Subject: [PATCH] Bugfix: un-stucked array key handling to prevent popup spam --- Linkace Launcher.user.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Linkace Launcher.user.js b/Linkace Launcher.user.js index 0c4c2c1..b55429f 100644 --- a/Linkace Launcher.user.js +++ b/Linkace Launcher.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name LinkAce Launcher // @namespace https://marvinscham.de -// @version 0.2 +// @version 0.3 // @description Creates a keyboard shortcut to add links to my instance of LinkAce // @author marvinscham // @match *://*/* @@ -14,10 +14,11 @@ let keysPressed = {}; document.addEventListener('keydown', (event) => { keysPressed[event.key] = true; -}); - -document.addEventListener('keyup', (event) => { - delete this.keysPressed[event.key]; + setTimeout( + function() { + keysPressed[event.key] = false; + }, 500 + ); }); window.addEventListener("load", function () { @@ -29,4 +30,4 @@ window.addEventListener("load", function () { window.open('https://bookmarks.xn--schmkerei-37a.de/bookmarklet/add?u=' + encodeURIComponent(url) + '&t=' + encodeURIComponent(title) + '&d=' + encodeURIComponent(description), '_blank', 'menubar=no,height=720,width=600,toolbar=no,scrollbars=yes,status=no,dialog=1'); } }); -})(); +});