From e55f4c2fe8a6e1d62a0b005777b46c80e360d37e Mon Sep 17 00:00:00 2001
From: memdmp <memdmp@estrogen.zone>
Date: Thu, 31 Jul 2025 22:48:01 +0200
Subject: feat: initial commit

---
 src/lib/Player/Keybinds.svelte | 47 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 src/lib/Player/Keybinds.svelte

(limited to 'src/lib/Player/Keybinds.svelte')

diff --git a/src/lib/Player/Keybinds.svelte b/src/lib/Player/Keybinds.svelte
new file mode 100644
index 0000000..756a865
--- /dev/null
+++ b/src/lib/Player/Keybinds.svelte
@@ -0,0 +1,47 @@
+<script lang="ts">
+	let {
+		frame = $bindable(),
+		frameCount,
+		fps,
+		playing = $bindable(),
+		playbackStarted = $bindable()
+	}: {
+		frame: number;
+		frameCount: number;
+		fps: number | undefined;
+		playing: boolean;
+		playbackStarted: number;
+	} = $props();
+</script>
+
+<svelte:window
+	onkeypress={(e) => {
+		switch (e.key) {
+			case ' ':
+				e.preventDefault();
+				playing = !playing;
+				if (playing) playbackStarted = performance.now();
+				break;
+
+			// default:
+			// 	if (dev) console.debug('Keypress:', e.key);
+			// 	break;
+		}
+	}}
+	onkeydown={(e) => {
+		switch (e.key) {
+			case 'ArrowLeft':
+				e.preventDefault();
+				frame = Math.max(frame - (e.ctrlKey ? (fps ?? 60) : 1), 0);
+				break;
+			case 'ArrowRight':
+				e.preventDefault();
+				frame = Math.min(frame + (e.ctrlKey ? (fps ?? 60) : 1), frameCount);
+				break;
+
+			// default:
+			// 	if (dev) console.debug('Keydown:', e.key);
+			// 	break;
+		}
+	}}
+/>
-- 
cgit v1.2.3

