mirror of
https://github.com/manilarome/the-glorious-startpage.git
synced 2025-01-05 21:09:07 +01:00
keybinding finish question mark??
This commit is contained in:
parent
af07931c2a
commit
76e2221c89
@ -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; };
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user