From db66c1d95708e329ef69fe959f0e8dd5fdc348e6 Mon Sep 17 00:00:00 2001 From: Gerome Matilla Date: Fri, 5 Jun 2020 10:22:20 +0800 Subject: [PATCH] keybindings cleanup --- js/keybindings.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/js/keybindings.js b/js/keybindings.js index 10f513a..cbc159f 100644 --- a/js/keybindings.js +++ b/js/keybindings.js @@ -22,19 +22,27 @@ document.addEventListener( } if (event.key === 'Escape') { + + event.preventDefault(); // If any of this are open, close it if (searchBoxVisility) { + // Hide searchbox toggleSearchBox(); searchBox.value = ''; return; + } else if (weatherScreenVisibility) { + toggleWeatherScreen(); return; + } else if (rightDashboardVisibility) { + toggleDashboard(); return; + } // Show web menu @@ -49,16 +57,8 @@ document.addEventListener( if (webMenuVisibility || weatherScreenVisibility || rightDashboardVisibility) return; - // Dont accept ctrl, alt, - // left window key, f5, f12, return - if (event.key === 'Control' || - event.key === 'Alt' || - event.key === 'Shift' || - event.key === 'Meta' || - event.key === 'F5' || - event.key === 'F12' || - event.key === 'Enter') - return; + // Only accept single charactered key and backspace to open search box + if ((event.key.length > 1) && (event.key !== 'Backspace')) return; // Open searchbox toggleSearchBox();