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

@@ -4,6 +4,8 @@ import { useAudio } from "@/hooks/useAudio";
import { useAppStore } from "@/stores/app";
import { useTheme } from "@/context/ThemeContext";
import { useNavigation } from "@/context/NavigationContext";
import { useKeyboard } from "@opentui/solid";
import { onMount } from "solid-js";
enum PlayerPaneType {
PLAYER = 1,
@@ -15,6 +17,32 @@ export function PlayerPage() {
const { theme } = useTheme();
const nav = useNavigation();
onMount(() => {
useKeyboard(
(keyEvent: any) => {
const isNext = keyEvent.key === "l" || keyEvent.key === "ArrowRight";
const isPrev = keyEvent.key === "h" || keyEvent.key === "ArrowLeft";
const isPlayPause = keyEvent.key === " " || keyEvent.key === "Enter";
if (isPlayPause) {
audio.togglePlayback();
return;
}
if (isNext) {
audio.seek(audio.currentEpisode()?.duration ?? 0);
return;
}
if (isPrev) {
audio.seek(0);
return;
}
},
{ release: false },
);
});
const progressPercent = () => {
const d = audio.duration();
if (d <= 0) return 0;