Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
945c9f7
refactor(hotkeys): use tanstack/hotkey (@fehmer)
fehmer Mar 20, 2026
c013ec7
move konami
fehmer Mar 20, 2026
2670988
review comments
fehmer Mar 20, 2026
a6d5b96
fix tab open cmdline, format
fehmer Mar 20, 2026
4a406b1
remove duplicate in globals.ts, move stuff around
fehmer Mar 20, 2026
e420414
restructure devtools
fehmer Mar 21, 2026
d37e894
sequence
Miodec Mar 21, 2026
3ebe9ab
dont import legacy code
Miodec Mar 21, 2026
dff214c
move event, use event in hotkey
Miodec Mar 21, 2026
5257a3a
move hasNewline and hasTab to states
fehmer Mar 21, 2026
be72607
dynamic hotkeys
fehmer Mar 21, 2026
6a74b51
fix hotkey handling?
fehmer Mar 21, 2026
672bc21
refactor
fehmer Mar 22, 2026
4ca983a
change modes notice
fehmer Mar 22, 2026
23f9b9d
fix styles?
fehmer Mar 23, 2026
534c9b4
Merge branch 'master' into feature/ts-hotkeys
fehmer Mar 24, 2026
9e70c23
Merge branch 'master' into feature/ts-hotkeys
fehmer Mar 24, 2026
2e00d96
Merge branch 'master' into feature/ts-hotkeys
Miodec Mar 25, 2026
430dbff
rename
Miodec Mar 25, 2026
479dc97
rename
Miodec Mar 25, 2026
df8aa1c
rename
Miodec Mar 25, 2026
b504467
refactor
Miodec Mar 25, 2026
6a9f2e2
prevent shift+tab to insert tab
fehmer Mar 25, 2026
8f839dc
ignore shift
Miodec Mar 25, 2026
2639ba9
prevent tab navigation
Miodec Mar 25, 2026
fec5bcb
one bug, two idiots, two fixes
fehmer Mar 25, 2026
4f9efa5
also ignore A
Miodec Mar 25, 2026
76240a3
quick restart off
Miodec Mar 25, 2026
8dbbe10
based on hotkey
Miodec Mar 25, 2026
81e4292
const for NoKey
fehmer Mar 25, 2026
a530cf2
brrahp
Miodec Mar 25, 2026
770d193
fixes
Miodec Mar 25, 2026
314e8bc
fix
Miodec Mar 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"@tanstack/pacer-lite": "0.2.1",
"@tanstack/query-db-collection": "1.0.27",
"@tanstack/solid-db": "0.2.10",
"@tanstack/solid-devtools": "0.8.0",
"@tanstack/solid-form": "1.28.4",
"@tanstack/solid-hotkeys": "0.4.2",
"@tanstack/solid-hotkeys-devtools": "0.4.3",
"@tanstack/solid-query": "5.90.23",
"@tanstack/solid-query-devtools": "5.91.3",
"@tanstack/solid-table": "8.21.3",
Expand All @@ -60,7 +63,6 @@
"hangul-js": "0.2.6",
"howler": "2.2.3",
"idb": "8.0.3",
"konami": "1.7.0",
"lz-ts": "1.1.2",
"modern-screenshot": "4.6.8",
"object-hash": "3.0.0",
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/html/pages/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@

<div class="tip">
tip: You can also change all these settings quickly using the command line (
<kbd>ctrl/cmd</kbd>
+
<kbd>shift</kbd>
+
<kbd>p</kbd>
or
<kbd>esc</kbd>
<mount data-component="commandlinehotkey"></mount>
)
</div>

Expand Down
1 change: 1 addition & 0 deletions frontend/src/styles/test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@

.textButton {
padding: 0.5em 1em;
align-items: center;
&.noInteraction {
pointer-events: none;
}
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/ts/components/common/Kbd.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { formatWithLabels, Hotkey } from "@tanstack/solid-hotkeys";
import { JSXElement } from "solid-js";

type Props =
| { hotkey: Hotkey; text?: undefined }
| { hotkey?: undefined; text: string };

export function Kbd(props: Props): JSXElement {
return (
<kbd>
{props.hotkey
? formatWithLabels(props.hotkey).toLowerCase().replace(/\+/g, " + ")
: props.text}
</kbd>
);
}
10 changes: 5 additions & 5 deletions frontend/src/ts/components/core/DevTools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { JSXElement, lazy, onMount, Suspense } from "solid-js";
let DevComponents: (() => JSXElement) | undefined;

if (import.meta.env.DEV) {
const LazyQueryDevtools = lazy(async () =>
import("@tanstack/solid-query-devtools").then((m) => ({
default: m.SolidQueryDevtools,
const LazyTanstackDevtools = lazy(async () =>
import("./TanstackDevtools").then((m) => ({
default: m.TanStackDevtools,
})),
);
const LazyDevOptionsModal = lazy(async () =>
Expand All @@ -19,7 +19,7 @@ if (import.meta.env.DEV) {
default: () => {
onMount(() => {
m.attachDevtoolsOverlay({
defaultOpen: true,
defaultOpen: false,
noPadding: true,
});
});
Expand All @@ -31,7 +31,7 @@ if (import.meta.env.DEV) {

DevComponents = () => (
<Suspense>
<LazyQueryDevtools />
<LazyTanstackDevtools />
<LazyDevOptionsModal />
<LazySolidDevtoolsOverlay />
</Suspense>
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/ts/components/core/TanstackDevtools.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TanStackDevtools as TsDevTools } from "@tanstack/solid-devtools";
import { hotkeysDevtoolsPlugin } from "@tanstack/solid-hotkeys-devtools";
import { SolidQueryDevtoolsPanel } from "@tanstack/solid-query-devtools";
import { JSXElement } from "solid-js";

import { queryClient } from "../../queries";

export function TanStackDevtools(): JSXElement {
return (
<TsDevTools
plugins={[
{
id: "tanstack-query",
name: "TanStack Query",
render: () => <SolidQueryDevtoolsPanel client={queryClient} />,
defaultOpen: true,
},
hotkeysDevtoolsPlugin(),
]}
config={{ defaultOpen: false }}
/>
);
}
17 changes: 17 additions & 0 deletions frontend/src/ts/components/hotkeys/CommandlineHotkey.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Show } from "solid-js";

import { hotkeys } from "../../states/hotkeys";
import { isFirefox } from "../../utils/misc";
import { Kbd } from "../common/Kbd";

export function CommandlineHotkey() {
return (
<>
<Kbd hotkey={hotkeys.commandline} />
<Show when={!isFirefox()}>
&nbsp;or&nbsp;
<Kbd hotkey="Mod+Shift+P" />
</Show>
</>
);
}
15 changes: 15 additions & 0 deletions frontend/src/ts/components/hotkeys/QuickRestartHotkey.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Hotkey } from "@tanstack/solid-hotkeys";
import { JSXElement } from "solid-js";

import { NoKey } from "../../input/hotkeys/utils";
import { hotkeys } from "../../states/hotkeys";
import { Kbd } from "../common/Kbd";

export function QuickRestartHotkey(): JSXElement {
const props = (): { hotkey: Hotkey } | { text: string } =>
hotkeys.quickRestart !== NoKey
? { hotkey: hotkeys.quickRestart }
: { text: "tab > enter" };

return <Kbd {...props()} />;
}
39 changes: 12 additions & 27 deletions frontend/src/ts/components/layout/footer/Keytips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,27 @@ import { JSXElement, Show } from "solid-js";

import { getConfig } from "../../../config/store";
import { getFocus } from "../../../states/test";
import { Conditional } from "../../common/Conditional";
import { CommandlineHotkey } from "../../hotkeys/CommandlineHotkey";
import { QuickRestartHotkey } from "../../hotkeys/QuickRestartHotkey";

export function Keytips(): JSXElement {
const userAgent = window.navigator.userAgent.toLowerCase();
const modifierKey =
userAgent.includes("mac") && !userAgent.includes("firefox")
? "cmd"
: "ctrl";

const commandKey = (): string =>
getConfig.quickRestart === "esc" ? "tab" : "esc";

return (
<Show when={getConfig.showKeyTips}>
<div
class="mb-8 text-center leading-loose transition-opacity"
class="mb-8 flex flex-col items-center gap-2 transition-opacity"
classList={{
"opacity-0": getFocus(),
}}
>
<Conditional
if={getConfig.quickRestart === "off"}
then={
<>
<kbd>tab</kbd> + <kbd>enter</kbd> - restart test
</>
}
else={
<>
<kbd>{getConfig.quickRestart}</kbd> - restart test
</>
}
/>
<br />
<kbd>{commandKey()}</kbd> or <kbd>{modifierKey}</kbd> + <kbd>shift</kbd>{" "}
+ <kbd>p</kbd> - command line
<div class="flex items-center gap-2">
<QuickRestartHotkey />
<span>- restart test</span>
</div>

<div class="flex items-center gap-2">
<CommandlineHotkey />
<span>- command line</span>
</div>
</div>
</Show>
);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/ts/components/mount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { queryClient } from "../queries";
import { qsa } from "../utils/dom";
import { DevTools } from "./core/DevTools";
import { Theme } from "./core/Theme";
import { CommandlineHotkey } from "./hotkeys/CommandlineHotkey";
import { Footer } from "./layout/footer/Footer";
import { Header } from "./layout/header/Header";
import { Overlays } from "./layout/overlays/Overlays";
Expand Down Expand Up @@ -34,6 +35,7 @@ const components: Record<string, () => JSXElement> = {
header: () => <Header />,
devtools: () => <DevTools />,
testconfig: () => <TestConfig />,
commandlinehotkey: () => <CommandlineHotkey />,
};

function mountToMountpoint(name: string, component: () => JSXElement): void {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/ts/components/pages/AboutPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { Button } from "../common/Button";
import { ChartJs } from "../common/ChartJs";
import { Fa } from "../common/Fa";
import { H2, H3 } from "../common/Headers";
import { CommandlineHotkey } from "../hotkeys/CommandlineHotkey";
import { QuickRestartHotkey } from "../hotkeys/QuickRestartHotkey";

export function AboutPage(): JSXElement {
const isOpen = () => getActivePage() === "about";
Expand Down Expand Up @@ -201,10 +203,8 @@ export function AboutPage(): JSXElement {
<section>
<H3 fa={{ icon: "fa-keyboard" }} text="keybinds" />
<p>
You can use <kbd>tab</kbd> and <kbd>enter</kbd> (or just{" "}
<kbd>tab</kbd> if you have quick tab mode enabled) to restart the
typing test. Open the command line by pressing <kbd>ctrl/cmd</kbd> +{" "}
<kbd>shift</kbd> + <kbd>p</kbd> or <kbd>esc</kbd> - there you can
You can use <QuickRestartHotkey /> to restart the typing test. Open
the command line by pressing <CommandlineHotkey /> - there you can
access all the functionality you need without touching your mouse.
</p>
</section>
Expand Down
22 changes: 13 additions & 9 deletions frontend/src/ts/elements/modes-notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import Format from "../singletons/format";
import { getActiveFunboxes, getActiveFunboxNames } from "../test/funbox/list";
import { escapeHTML, getMode2 } from "../utils/misc";
import { qsr } from "../utils/dom";
import { getLoadedChallenge } from "../states/test";
import {
wordsHaveNewline,
wordsHaveTab,
getLoadedChallenge,
} from "../states/test";

configEvent.subscribe(({ key }) => {
const configKeys: ConfigEventKey[] = [
Expand Down Expand Up @@ -57,28 +61,28 @@ export async function update(): Promise<void> {
);
}

if (TestWords.hasTab) {
if (wordsHaveTab()) {
if (Config.quickRestart === "esc") {
testModesNotice.appendHtml(
`<div class="textButton noInteraction"><i class="fas fa-long-arrow-alt-right"></i>shift + tab to open commandline</div>`,
`<div class="textButton noInteraction"><kbd>shift + tab</kbd><span> to open commandline</span></div>`,
);
testModesNotice.appendHtml(
`<div class="textButton noInteraction"><i class="fas fa-level-down-alt fa-rotate-90"></i>shift + esc to restart</div>`,
`<div class="textButton noInteraction"><kbd>esc</kbd><span> to restart</span></div>`,
);
}
if (Config.quickRestart === "tab") {
testModesNotice.appendHtml(
`<div class="textButton noInteraction"><i class="fas fa-level-down-alt fa-rotate-90"></i>shift + tab to restart</div>`,
`<div class="textButton noInteraction"><kbd>shift + tab</kbd><span> to restart</span></div>`,
);
}
}

if (
(TestWords.hasNewline || Config.funbox.includes("58008")) &&
(wordsHaveNewline() || Config.funbox.includes("58008")) &&
Config.quickRestart === "enter"
) {
testModesNotice.appendHtml(
`<div class="textButton noInteraction"><i class="fas fa-level-down-alt fa-rotate-90"></i>shift + enter to restart</div>`,
`<div class="textButton noInteraction"><kbd>shift + enter</kbd><span> to restart</span></div>`,
);
}

Expand All @@ -88,7 +92,7 @@ export async function update(): Promise<void> {
testModesNotice.appendHtml(
`<div class="textButton noInteraction"><i class="fas fa-book"></i>${escapeHTML(
customTextName,
)} (shift + enter to save progress)</div>`,
)} (<kbd>shift + enter</kbd><span> to save progress</span>)</div>`,
);
}

Expand All @@ -101,7 +105,7 @@ export async function update(): Promise<void> {

if (Config.mode === "zen") {
testModesNotice.appendHtml(
`<div class="textButton noInteraction"><i class="fas fa-poll"></i>shift + enter to finish zen </div>`,
`<div class="textButton noInteraction"><kbd>shift + enter</kbd><span> to finish zen</span></div>`,
);
}

Expand Down
50 changes: 0 additions & 50 deletions frontend/src/ts/event-handlers/global.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import * as Misc from "../utils/misc";
import * as PageTransition from "../legacy-states/page-transition";
import { Config } from "../config/store";
import * as TestWords from "../test/test-words";
import * as Commandline from "../commandline/commandline";
import { showErrorNotification } from "../states/notifications";
import { getActivePage } from "../states/core";
import { ModifierKeys } from "../constants/modifier-keys";
import { focusWords } from "../test/test-ui";
import * as TestLogic from "../test/test-logic";
import { navigate } from "../controllers/route-controller";
import { isInputElementFocused } from "../input/input-element";
import * as TestState from "../test/test-state";
import { isDevEnvironment } from "../utils/env";
Expand All @@ -35,52 +31,6 @@ document.addEventListener("keydown", (e) => {
}
}
}

if (
(e.key === "Escape" && Config.quickRestart !== "esc") ||
(e.key === "Tab" &&
Config.quickRestart === "esc" &&
!TestWords.hasTab &&
!e.shiftKey) ||
(e.key === "Tab" &&
Config.quickRestart === "esc" &&
TestWords.hasTab &&
e.shiftKey) ||
(e.key.toLowerCase() === "p" && (e.metaKey || e.ctrlKey) && e.shiftKey)
) {
const popupVisible = Misc.isAnyPopupVisible();
if (!popupVisible) {
e.preventDefault();
Commandline.show();
}
}

if (!isInputElementFocused()) {
const isInteractiveElement =
document.activeElement?.tagName === "INPUT" ||
document.activeElement?.tagName === "TEXTAREA" ||
document.activeElement?.tagName === "SELECT" ||
document.activeElement?.tagName === "BUTTON" ||
document.activeElement?.classList.contains("button") === true ||
document.activeElement?.classList.contains("textButton") === true;

if (
(e.key === "Tab" &&
Config.quickRestart === "tab" &&
!isInteractiveElement) ||
(e.key === "Escape" && Config.quickRestart === "esc") ||
(e.key === "Enter" &&
Config.quickRestart === "enter" &&
!isInteractiveElement)
) {
e.preventDefault();
if (getActivePage() === "test") {
TestLogic.restart({ isQuickRestart: !e.shiftKey });
} else {
void navigate("");
}
}
}
});

//stop space scrolling
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/ts/events/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { createEvent } from "../hooks/createEvent";

export const restartTestEvent = createEvent();
export const restartTestEvent = createEvent<
{ isQuickRestart?: boolean } | undefined
>();
2 changes: 2 additions & 0 deletions frontend/src/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import "./ready";
import { setVersion } from "./states/core";
import { loadFromLocalStorage } from "./config/lifecycle";

import "./input/hotkeys";

// Lock Math.random
Object.defineProperty(Math, "random", {
value: Math.random,
Expand Down
Loading
Loading