improved quick restart esc

pressing tab now opens the command line
you can still insert tab as character (shift tab to open the commandline if text has tab)
closes #3233
This commit is contained in:
Miodec 2022-06-28 17:57:10 +02:00
parent 9da5e441be
commit 5bbb6a62a4
6 changed files with 51 additions and 15 deletions

View file

@ -611,7 +611,21 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
const modalVisible =
!$("#commandLineWrapper").hasClass("hidden") || popupVisible;
if (Config.quickRestart === "tab") {
if (Config.quickRestart === "esc") {
// dont do anything special
if (modalVisible) return;
// dont do anything on login so we can tab/esc betweeen inputs
if (ActivePage.get() === "login") return;
event.preventDefault();
// insert tab character if needed (only during the test)
if (!TestUI.resultVisible && shouldInsertTabCharacter) {
handleChar("\t", TestInput.input.current.length);
setWordsInput(" " + TestInput.input.current);
return;
}
} else if (Config.quickRestart === "tab") {
// dont do anything special
if (modalVisible) return;

View file

@ -7,6 +7,8 @@ import * as DB from "../db";
import * as Notifications from "../elements/notifications";
import * as AnalyticsController from "../controllers/analytics-controller";
import * as PageTransition from "../states/page-transition";
import * as TestWords from "../test/test-words";
import * as ActivePage from "../states/active-page";
import { Auth } from "../firebase";
import { isAnyPopupVisible } from "../utils/misc";
@ -389,7 +391,8 @@ $(document).ready(() => {
if (PageTransition.get()) return event.preventDefault();
// opens command line if escape or ctrl/cmd + shift + p
if (
event.key === "Escape" &&
((event.key === "Escape" && Config.quickRestart !== "esc") ||
(event.key === "Tab" && Config.quickRestart === "esc")) &&
!$("#commandLineWrapper").hasClass("hidden")
) {
if (CommandlineLists.current.length > 1) {
@ -404,17 +407,26 @@ $(document).ready(() => {
}
if (
(event.key === "Escape" && Config.quickRestart !== "esc") ||
(event.key === "Tab" &&
Config.quickRestart === "esc" &&
!TestWords.hasTab &&
!event.shiftKey) ||
(event.key === "Tab" &&
Config.quickRestart === "esc" &&
TestWords.hasTab &&
event.shiftKey) ||
(event.key &&
event.key.toLowerCase() === "p" &&
(event.metaKey || event.ctrlKey) &&
event.shiftKey)
) {
event.preventDefault();
const popupVisible = isAnyPopupVisible();
if (popupVisible) return;
if (Config.quickRestart === "esc" && ActivePage.get() === "login") return;
event.preventDefault();
if (Config.singleListCommandLine == "on") {
useSingleListCommandLine(false);
} else {

View file

@ -40,9 +40,15 @@ export async function update(): Promise<void> {
}
if (TestWords.hasTab) {
$(".pageTest #testModesNotice").append(
`<div class="textButton"><i class="fas fa-long-arrow-alt-right"></i>shift + tab to restart</div>`
);
if (Config.quickRestart === "esc") {
$(".pageTest #testModesNotice").append(
`<div class="textButton"><i class="fas fa-long-arrow-alt-right"></i>shift + tab to open commandline</div>`
);
} else {
$(".pageTest #testModesNotice").append(
`<div class="textButton"><i class="fas fa-long-arrow-alt-right"></i>shift + tab to restart</div>`
);
}
}
if (TestState.activeChallenge) {

View file

@ -322,8 +322,12 @@ export function restart(
}
if (ActivePage.get() == "test" && !TestUI.resultVisible) {
if (!ManualRestart.get()) {
if (TestWords.hasTab) {
if (!event?.shiftKey) return;
if (
TestWords.hasTab &&
!event?.shiftKey &&
Config.quickRestart !== "esc"
) {
return;
}
if (Config.mode !== "zen") event?.preventDefault();
if (

View file

@ -22,7 +22,7 @@ export function updateKeytips(): void {
if (Config.quickRestart === "esc") {
$("#bottom .keyTips").html(`
<key>esc</key> - restart test<br>
<key>ctrl/cmd</key>+<key>shift</key>+<key>p</key> - command line`);
<key>tab</key> or <key>ctrl/cmd</key>+<key>shift</key>+<key>p</key> - command line`);
} else if (Config.quickRestart === "tab") {
$("#bottom .keyTips").html(`
<key>tab</key> - restart test<br>

View file

@ -168,11 +168,11 @@
<key>tab</key>
or
<key>esc</key>
to quickly restart the test, or to quickly jump to the test page. The
"tab" setting disables tab navigation on the website, while the "esc"
disables opening the command line with
<key>esc</key>
.
to quickly restart the test, or to quickly jump to the test page. Both
options disable tab navigation on most parts of the website. Using the
"esc" option will move opening the commandline to the
<key>tab</key>
key.
</div>
<div class="buttons">
<div