We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c6046bd + 470f4f8 commit 01b9da7Copy full SHA for 01b9da7
frontend/src/components/Media/MediaView.tsx
@@ -18,6 +18,22 @@ const MediaView: React.FC<MediaViewProps> = ({
18
setGlobalIndex((currentPage - 1) * itemsPerPage + initialIndex);
19
}, [initialIndex, currentPage, itemsPerPage]);
20
21
+ useEffect(() => {
22
+ const handleKeyDown = (e: KeyboardEvent) => {
23
+ if (e.key === "ArrowRight") {
24
+ handleNextItem();
25
+ } else if (e.key === "ArrowLeft") {
26
+ handlePrevItem();
27
+ }
28
+ };
29
+
30
+ window.addEventListener("keydown", handleKeyDown);
31
32
+ return () => {
33
+ window.removeEventListener("keydown", handleKeyDown);
34
35
+ }, [globalIndex]);
36
37
function handlePrevItem() {
38
if (globalIndex > 0) {
39
setGlobalIndex(globalIndex - 1);
0 commit comments