From cdc94514d9f6eb1865bd0b64c17f5e57affb0a5b Mon Sep 17 00:00:00 2001 From: Thomas Hallock Date: Wed, 26 Nov 2025 14:59:36 -0600 Subject: [PATCH] feat(know-your-world): add 'H' keyboard shortcut for hint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Press 'H' to toggle the hint bubble (similar to 'G' for give up) - Only works when a hint is available for the current region - Doesn't trigger when typing in input fields - Updated button label to show "(H)" keyboard shortcut 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../know-your-world/components/MapRenderer.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/web/src/arcade-games/know-your-world/components/MapRenderer.tsx b/apps/web/src/arcade-games/know-your-world/components/MapRenderer.tsx index ff83c515..440b1c22 100644 --- a/apps/web/src/arcade-games/know-your-world/components/MapRenderer.tsx +++ b/apps/web/src/arcade-games/know-your-world/components/MapRenderer.tsx @@ -1052,12 +1052,22 @@ export function MapRenderer({ } }, [giveUpReveal?.timestamp]) // Re-run when timestamp changes - // Shift key listener - show magnifier when Shift is held + // Keyboard shortcuts - Shift for magnifier, H for hint useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { + // Don't trigger shortcuts if user is typing in an input + if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) { + return + } + if (e.key === 'Shift' && !e.repeat) { setShiftPressed(true) } + + // 'H' key to toggle hint bubble + if ((e.key === 'h' || e.key === 'H') && !e.repeat && hasHint) { + setShowHintBubble((prev) => !prev) + } } const handleKeyUp = (e: KeyboardEvent) => { @@ -1073,7 +1083,7 @@ export function MapRenderer({ window.removeEventListener('keydown', handleKeyDown) window.removeEventListener('keyup', handleKeyUp) } - }, []) + }, [hasHint]) const [labelPositions, setLabelPositions] = useState([]) const [smallRegionLabelPositions, setSmallRegionLabelPositions] = useState< @@ -4120,7 +4130,7 @@ export function MapRenderer({ }, })} > - 💡 Hint + 💡 Hint (H) {/* Speech bubble for hint */}