summaryrefslogtreecommitdiff
path: root/apps/web/src/components/editor/panels
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-04-06 01:51:09 +0200
committerMaze Winther <mazewinther@gmail.com>2026-04-06 01:51:09 +0200
commit05243616eaf597c8e81b9401ba09b425928ebf95 (patch)
treee616dc41c6e289f1e5c8381c3436103a7c6ed7c0 /apps/web/src/components/editor/panels
parentccd552a1c034520cd9ebe51648d2441a92bfeda4 (diff)
downloadopencut-05243616eaf597c8e81b9401ba09b425928ebf95.tar.gz
refactor: use useShiftKey hook in bezier graph
Diffstat (limited to 'apps/web/src/components/editor/panels')
-rw-r--r--apps/web/src/components/editor/panels/timeline/graph-editor/bezier-graph.tsx20
1 files changed, 3 insertions, 17 deletions
diff --git a/apps/web/src/components/editor/panels/timeline/graph-editor/bezier-graph.tsx b/apps/web/src/components/editor/panels/timeline/graph-editor/bezier-graph.tsx
index 32f39174..f607dc7a 100644
--- a/apps/web/src/components/editor/panels/timeline/graph-editor/bezier-graph.tsx
+++ b/apps/web/src/components/editor/panels/timeline/graph-editor/bezier-graph.tsx
@@ -1,6 +1,7 @@
"use client";
-import { useEffect, useRef, useState, type PointerEvent } from "react";
+import { useRef, useState, type PointerEvent } from "react";
+import { useShiftKey } from "@/hooks/use-shift-key";
import { getBezierPoint } from "@/lib/animation/bezier";
import type { NormalizedCubicBezier } from "@/lib/animation/types";
import { cn } from "@/utils/ui";
@@ -85,26 +86,11 @@ export function BezierGraph({
}) {
const svgRef = useRef<SVGSVGElement>(null);
const [activeHandle, setActiveHandle] = useState<BezierHandle | null>(null);
- const isShiftPressedRef = useRef(false);
+ const isShiftPressedRef = useShiftKey();
const latestValueRef = useRef(value);
latestValueRef.current = value;
- useEffect(() => {
- const onKeyDown = (event: KeyboardEvent) => {
- if (event.key === "Shift") isShiftPressedRef.current = true;
- };
- const onKeyUp = (event: KeyboardEvent) => {
- if (event.key === "Shift") isShiftPressedRef.current = false;
- };
- window.addEventListener("keydown", onKeyDown);
- window.addEventListener("keyup", onKeyUp);
- return () => {
- window.removeEventListener("keydown", onKeyDown);
- window.removeEventListener("keyup", onKeyUp);
- };
- }, []);
-
function getPointerPosition({
event,
}: {