mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 15:26:15 +08:00
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:
parent
9da5e441be
commit
5bbb6a62a4
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue