From 3644641c0139dbaaa41a4786fe1e7e58d5069952 Mon Sep 17 00:00:00 2001 From: Primo <44984918+m-primo@users.noreply.github.com> Date: Sun, 17 Oct 2021 16:52:49 +0200 Subject: [PATCH] fix keycode problem --- js/script.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/js/script.js b/js/script.js index e8bcd90..b9c6156 100644 --- a/js/script.js +++ b/js/script.js @@ -48,9 +48,7 @@ function getName(name, i = 0) { function KeyCode(event) { let code; - if(event.key !== undefined) { - code = event.key; - } else if(event.keyIdentifier !== undefined) { + if(event.keyIdentifier !== undefined) { code = event.keyIdentifier; } else if(event.keyCode !== undefined) { code = event.keyCode; @@ -218,8 +216,8 @@ getName('q', 0).focus(); getName('q', 0).addEventListener('keyup', function(e){ e.preventDefault(); const key_code = KeyCode(e); - if(key_code === 13) doSearch(); - if(key_code === 27) clearSearch(); + if(key_code == 13) doSearch(); + if(key_code == 27) clearSearch(); }); getID('click-to-clear-search').onclick = function(){