f9f6233b69
CI / build-and-push (push) Successful in 33s
Addresses broken interactions (notification bell, browser dialogs), missing feedback states (disabled buttons, pricing changes, paused indicator), unclear affordances (research queue, model tuning, funding requirements), and navigation gaps (hash routing, keyboard shortcuts, clickable dashboard cards, sidebar grouping, tutorial hints). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
979 B
TypeScript
35 lines
979 B
TypeScript
import { useEffect } from 'react';
|
|
import { useGameStore } from '@/store';
|
|
import type { GameSpeed } from '@ai-tycoon/shared';
|
|
|
|
export function useKeyboardShortcuts() {
|
|
useEffect(() => {
|
|
const handler = (e: KeyboardEvent) => {
|
|
const target = e.target as HTMLElement;
|
|
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.tagName === 'SELECT') return;
|
|
|
|
const store = useGameStore.getState();
|
|
|
|
switch (e.key) {
|
|
case ' ':
|
|
e.preventDefault();
|
|
store.togglePause();
|
|
break;
|
|
case '1':
|
|
store.setGameSpeed(1 as GameSpeed);
|
|
break;
|
|
case '2':
|
|
store.setGameSpeed(2 as GameSpeed);
|
|
break;
|
|
case '3':
|
|
store.setGameSpeed(5 as GameSpeed);
|
|
break;
|
|
case 'Escape':
|
|
break;
|
|
}
|
|
};
|
|
window.addEventListener('keydown', handler);
|
|
return () => window.removeEventListener('keydown', handler);
|
|
}, []);
|
|
}
|