diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 65c03e7..466d1e3 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -9,6 +9,7 @@ function App() { const [showAbout, setShowAbout] = useState(false) const { articles, loading, fetchArticles } = useWikiArticles() const observerTarget = useRef(null) + const containerRef = useRef(null) const handleObserver = useCallback( (entries: IntersectionObserverEntry[]) => { @@ -37,8 +38,25 @@ function App() { fetchArticles() }, []) + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent) => { + if (!containerRef.current) return; + + if (event.key === 'ArrowRight') { + // Scroll down (next card) + containerRef.current.scrollBy({ top: window.innerHeight, behavior: 'smooth' }); + } else if (event.key === 'ArrowLeft') { + // Scroll up (previous card) + containerRef.current.scrollBy({ top: -window.innerHeight, behavior: 'smooth' }); + } + }; + + window.addEventListener('keydown', handleKeyDown); + return () => window.removeEventListener('keydown', handleKeyDown); + }, []); + return ( -
+