From 7935b3685fb0e80df3c0ebadce51fde6593b4245 Mon Sep 17 00:00:00 2001 From: KatieFrogs <23621460+KatieFrogs@users.noreply.github.com> Date: Fri, 25 Feb 2022 21:57:10 +0300 Subject: [PATCH] Fix key events in the search box --- public/src/js/keyboard.js | 6 +++++- public/src/js/pageevents.js | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/public/src/js/keyboard.js b/public/src/js/keyboard.js index 8a93c88..d72641c 100644 --- a/public/src/js/keyboard.js +++ b/public/src/js/keyboard.js @@ -68,7 +68,11 @@ class Keyboard{ } keyEvent(event){ var key = event.key.toLowerCase() - if( + if(event.target.tagName === "INPUT"){ + if(key === "escape"){ + event.preventDefault() + } + }else if( key === "escape" || key === "backspace" || key === "tab" || diff --git a/public/src/js/pageevents.js b/public/src/js/pageevents.js index b6d2a39..de94814 100644 --- a/public/src/js/pageevents.js +++ b/public/src/js/pageevents.js @@ -94,7 +94,9 @@ class PageEvents{ } if(this.kbd.indexOf(event.key.toLowerCase()) !== -1){ this.lastKeyEvent = Date.now() - event.preventDefault() + if(event.target.tagName !== "INPUT"){ + event.preventDefault() + } } this.keyListeners.forEach(addedKeyCode => { this.checkListener(addedKeyCode.get("all"), event)