diff --git a/src/components/TerminalCommand.tsx b/src/components/TerminalCommand.tsx index 9decf42..0d29936 100644 --- a/src/components/TerminalCommand.tsx +++ b/src/components/TerminalCommand.tsx @@ -1,5 +1,5 @@ import { useState, useRef, useEffect } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useNavigate, useLocation } from 'react-router-dom'; import { motion, AnimatePresence } from 'framer-motion'; import { Terminal, X } from 'lucide-react'; import { useSettings } from '@/contexts/SettingsContext'; @@ -70,9 +70,13 @@ const TerminalCommand = () => { const inputRef = useRef(null); const outputRef = useRef(null); const navigate = useNavigate(); + const location = useLocation(); const { playSound } = useSettings(); const { unlockAchievement } = useAchievements(); + // Check if user is on a game page + const isOnGamePage = location.pathname.startsWith('/games/'); + useEffect(() => { if (isOpen && inputRef.current) { inputRef.current.focus(); @@ -98,8 +102,8 @@ const TerminalCommand = () => { playSound('beep'); } - // Open terminal when pressing "/" (only if not in input) - if (e.key === '/' && !isOpen && !isInputFocused) { + // Open terminal when pressing "/" (only if not in input and not on a game page) + if (e.key === '/' && !isOpen && !isInputFocused && !isOnGamePage) { e.preventDefault(); setIsOpen(true); playSound('beep'); @@ -114,7 +118,7 @@ const TerminalCommand = () => { window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); - }, [isOpen, playSound]); + }, [isOpen, playSound, isOnGamePage]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault();