Have Esc always close commandline/leaderboards

This commit is contained in:
SeerLite 2021-01-07 18:01:31 -03:00
parent 139337fb5a
commit 1b2e50f8d6

View file

@ -1770,22 +1770,13 @@ $("#commandLine input").keyup((e) => {
$(document).ready((e) => {
$(document).keydown((event) => {
//escape
if (
(event.keyCode == 27 && !config.swapEscAndTab) ||
(event["keyCode"] == 9 && config.swapEscAndTab)
) {
if (event.keyCode == 27 || (event.keyCode == 9 && config.swapEscAndTab)) {
event.preventDefault();
if (!$("#leaderboardsWrapper").hasClass("hidden")) {
//maybe add more condition for closing other dialogs in the future as well
event.preventDefault();
hideLeaderboards();
return;
} else if ($("#commandLineWrapper").hasClass("hidden")) {
if (config.singleListCommandLine == "on")
useSingleListCommandLine(false);
else currentCommands = [commands];
showCommandLine();
} else {
} else if (!$("#commandLineWrapper").hasClass("hidden")) {
if (currentCommands.length > 1) {
currentCommands.pop();
$("#commandLine").removeClass("allCommands");
@ -1799,6 +1790,11 @@ $(document).ready((e) => {
} else {
setTheme(config.theme);
}
} else if (event.keyCode == 9 || !config.swapEscAndTab) {
if (config.singleListCommandLine == "on")
useSingleListCommandLine(false);
else currentCommands = [commands];
showCommandLine();
}
}
});