keybinding finish question mark??

This commit is contained in:
Gerome Matilla 2020-06-04 15:18:32 +08:00
parent af07931c2a
commit 76e2221c89

View File

@ -5,21 +5,70 @@ let keysPressed = {};
document.addEventListener(
'keydown',
(event) => {
event.preventDefault();
keysPressed[event.key] = true;
keysPressed[event.key] = true;
// Open dashboard
if (keysPressed['Alt'] && event.key === 's') {
event.preventDefault();
toggleDashboard();
return;
} else if (keysPressed['Alt'] && event.key === 'e') {
event.preventDefault();
toggleWebMenu();
return;
} else if (keysPressed['Alt'] && event.key === 'x') {
event.preventDefault();
toggleWeatherScreen();
return;
}
if (event.key === 'Escape') {
// If searchbox is visible, hide and clear input field
if (searchBoxVisility) {
// Hide searchbox
toggleSearchBox();
searchBox.value = '';
return;
};
// Show web menu
toggleWebMenu();
return;
}
if (searchBoxVisility === false) {
// Don't show searchbox when web menu, dashboard
// and weather screen is open
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;
// Open searchbox
toggleSearchBox();
} else {
// Backspacing while there's no search query will hide searhbox
// Will also hide if you hit enter
if ((event.key === 'Backspace' || event.key === 'Enter') &&
searchBox.value < 1) { toggleSearchBox(); return; };
}
}
);