mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
18 lines
520 B
TypeScript
18 lines
520 B
TypeScript
import { useEffect } from "react";
|
|||
|
|
import { usePlaybackStore } from "@/stores/playback-store";
|
||
|
|
|
||
|
|
export function usePlaybackControls() {
|
||
|
|
const { toggle } = usePlaybackStore();
|
||
|
|
|
||
|
|
useEffect(() => {
|
||
|
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||
|
|
if (e.code === "Space" && e.target === document.body) {
|
||
|
|
e.preventDefault();
|
||
|
|
toggle();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
document.addEventListener("keydown", handleKeyDown);
|
||
|
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
||
|
|
}, [toggle]);
|
||
|
|
}
|