temp keyboard handling

This commit is contained in:
2026-02-20 23:42:29 -05:00
parent 1e6618211a
commit b45e7bf538
6 changed files with 210 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { createSignal, For } from "solid-js";
import { createSignal, For, onMount } from "solid-js";
import { useKeyboard } from "@opentui/solid";
import { SourceManager } from "./SourceManager";
import { useTheme } from "@/context/ThemeContext";
@@ -33,6 +33,31 @@ export function SettingsPage() {
return nav.activeDepth() === depth;
};
onMount(() => {
useKeyboard(
(keyEvent: any) => {
const isDown =
keyEvent.key === "j" || keyEvent.key === "ArrowDown";
const isUp =
keyEvent.key === "k" || keyEvent.key === "ArrowUp";
const isSelect =
keyEvent.key === "Enter" || keyEvent.key === " ";
if (isSelect) {
nav.setActiveDepth((nav.activeDepth() % SettingsPaneCount) + 1);
return;
}
const nextDepth = isDown
? (nav.activeDepth() % SettingsPaneCount) + 1
: (nav.activeDepth() - 2 + SettingsPaneCount) % SettingsPaneCount + 1;
nav.setActiveDepth(nextDepth);
},
{ release: false },
);
});
return (
<box flexDirection="column" gap={1} height="100%" width="100%">
<box flexDirection="row" gap={1}>