/dm-game:menu-navigationfrom dm-game
Manages focus and navigation inside game menus for keyboard, mouse, and gamepad. Covers focus placement, arrow/D-pad movement with wrap rules, grid spatial navigation, shared highlight, focus ring, focus trapping, and hotkey coexistence.
Ships in dm-game. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Purpose: Any menu works by keyboard alone, by pad alone, by mouse alone, and when the player switches between them mid-menu. Focus is never lost, never in two places, and never behind the screen the player is looking at.
Sources:
inert and <dialog>.showModal() (both Baseline). The modal
makes the rest of the page inert and puts the dialog in the top layer.PlayMenuTyped sketch: references/nav.ts.
| Failure | Seen in | Root cause |
|---|---|---|
| Settings screen unreachable by keyboard or pad | redshifted | Canvas-drawn panel with no focusables; a navigation helper existed and was never wired |
| Every hotkey dead after one click on a HUD button | volatile-state-redux (read from code, not reproduced) | "Block hotkeys while a button has focus", applied to all keys |
| Shop loses keyboard focus every second | logarithmic (read from code, not reproduced) | innerHTML re-render at 1 Hz while open |
| Focus lands on the first item, not where the player came from | Hard Deck | Pop focuses "first item of the new top" |
| Gameplay Tab fights menu Tab | free-horses (inference) | Default binding on Tab, with HUD buttons in the tab order |
| A highlight outlives the cursor | gravelight (fixed) | Hover and keyboard tracked as two highlights |
Build menus as DOM over the canvas: <dialog>, real <button> and
<input type="range">, and inert for anything covered. That gives you, for
free:
A canvas-drawn menu must rebuild all of that:
Gravelight and redshifted both paid that. Draw a menu in canvas only when it must live in world space (diegetic UI; see hud-readouts). Even then, mirror its state into hidden DOM controls so focus and assistive tech have something real. Volatile-state-redux keeps DOM counterparts for critical canvas facts for exactly this reason.
data-default attribute on it.showModal() makes everything outside the dialog inert, so Tab
can't escape. For panes that aren't dialogs, set inert on what they cover
(free-horses).All directional input goes through move(direction): arrows, Tab, D-pad, stick.
next = (i + dir + n) % n, wrapping. Skip disabled and hidden items
(getClientRects().length === 0).primary + 2 × orthogonal distance. Starting value: weight 2.
Test: across the whole grid, does every pair of adjacent cells reach each other
in one press? If diagonal neighbours win over straight ones, raise the weight.
Don't wrap at grid edges (XAG 112).el.scrollIntoView({ block: 'nearest' }).
Free-horses had to stabilise an Options pane that scrolled under focus.pointerover, which bubbles) focuses it. The
highlight follows the mouse, and the next key press continues from there.
Skip it while the pointer is locked: there is no visible cursor (see
pointer-lock)..hl) that follows real focus through one
focusin listener per screen, as well as :focus-visible. Then game-shell's
focus restore, showModal()'s autofocus and a Tab all move it, and no stale
highlight is left behind.data-capturing on itself while a
capture is live.
A focused control consumes only the keys it uses:
Every other key still reaches hotkeys and the shell. Never block all hotkeys because a button has focus (volatile-state-redux).
During play, HUD buttons have tabindex="-1" and the canvas holds focus, so
Tab and Space belong to the game. Menus are where Tab navigates.
pad(),
where the fresh-press guard lives.
pad() first, then this skill's D-pad and stick
handling, then gameplay. A press consumed by the shell, such as the A that starts
a remap capture, is never seen again in the same frame.input
and change, as arrow keys do natively. Settings saves on change, so a pad
nudge that fired only input would never persist. This is Hard Deck's
nudgeSlider.Re-rendering a menu with innerHTML or replaceChildren destroys the focused
element; focus falls to <body>. Update text and attributes in place. If a rebuild
is unavoidable, remember the focused item's data-id and refocus it afterwards.
That costs one line, and logarithmic's shop lost focus every second without it.
<input type="text"> has focus. Up/down can still leave the field (XAG 112's "the
input that moved focus in moves it out").Each line names what the check cannot see.
press_key, not
dispatchEvent). Every control is reachable and operable, and focus is always
visible. Blind to: screen-reader output.document.activeElement before open, compare after close.
Blind to: screens reachable only in states the script doesn't reach.Test: a keyboard-only player and a pad-only player can each change a volume, remap a key and start a run without touching the mouse. If either can't, nothing else on this list matters yet.
Three tight links. Everything else routes through the map, so adding a skill
touches one file rather than twenty: references/routing-map.md (in
game-design).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub rbergman/dark-matter-marketplace --plugin dm-game40 skills in this plugin
/accessibility-designUse when designing any player-facing feature, evaluating a game for accessibility, responding to accessibility feedback, designing difficulty or assist options, adding subtitle/caption systems, implementing input remapping, or when a player reports they can't play. Covers the four accessibility pillars (visual, auditory, motor, cognitive), implementation tiers, colorblind design, subtitle standards, input accessibility, and testing methodology. Accessibility is a design discipline, not a post-launch checklist./async-and-socialSocial and competitive design that does not require players to be online together: ghost/replay data, leaderboards, asynchronous PvP, offline vulnerability, and anti-snowball mechanics. Use when adding leaderboards or high-score tables, designing ghost races or replay challenges, letting players attack or compete against absent opponents, deciding what social signal a single-player game should carry, or when matches and runs feel decided in the first minutes. Anti-snowball applies to single-player roguelikes and simulations too, not just PvP. For real-time multiplayer architecture, matchmaking, guilds, and moderation, this skill deliberately does not cover them — those are large specialities and belong in dedicated references./audio-designUse when designing how audio communicates game state, creates emotion, and serves as a feedback system. Activate for sound effect design, adaptive music systems, spatial audio, ambient soundscapes, audio priority and ducking, emotional audio design, and audio accessibility. Also activate when audio feels disconnected from gameplay, when players routinely play on mute (a design failure signal), when evaluating whether the audio stack has appropriate layering and variation, or when planning how music responds to gameplay context. This skill treats audio as a design system — not audio engineering or production, but the intentional design of what players hear, when, and why. Covers the full audio stack from music and ambience through sound effects, UI audio, and voice./camera-controlControlling a 2D or top-down game camera, not juicing it: a pure 'where it wants to be' target kept separate from 'how it gets there'; exponential damping versus a critically damped spring, with halflife as the tuning unit; velocity look-ahead and an aim lead on its own slow clock; zoom as a product of named factors (player base zoom, wheel, screen size, speed); combat framing that zooms out to keep every threat on screen, with a floor; an optional rotate-with-ship (heading-follow) mode and what it does to the HUD; shake applied only at render and never to the aim; one pair of world/screen conversions; and the camera options players expect. Use when building or reviewing a follow camera, adding zoom or a camera options tab, or when players say 'the view jumped when my mouse came back', 'I got shot from off screen', 'I can't see far enough ahead', 'the zoom makes me sick', 'it's too floaty' or 'too stiff', or 'the arrow points the wrong way'. Shake, punch and the trauma budget are game-feel's./cosmic-horror-registerTone, diction, and sensory palette for cosmic-horror game narrative — Lovecraftian, weird-fiction, eldritch, Arkham-adjacent, deep-time or deep-space dread. Use when writing or reviewing in-game text, story bibles, item descriptions, or interstitials for a cosmic-horror game; when horror prose reads as generic spooky rather than cosmic; when the mystery is being over-explained; or when a draft is leaning on words like eldritch, unspeakable, or indescribable to do the work. Also the worked example of the six-slot register template — read the Register template section to build folk-horror, noir, comic, or any other tonal register the same way. Layers on top of game-narrative-craft, which supplies the structural rules; this skill supplies only tone./data-driven-designTelemetry and analytics for games: event taxonomy and schema, engagement/progression/economy/balance/UX metrics, funnel analysis, A/B testing and when not to, cohort analysis, dashboard design, and the interpretation traps — Goodhart's Law, Simpson's paradox, survivorship bias, over-optimisation. Use when instrumenting a game, deciding what to measure, reading a retention or funnel drop, comparing cohorts, or when a metric moved and you need to know whether it means anything. Data-informed, not data-driven: numbers say what happened, not why. For pre-ship qualitative evidence use playtest-design.Other plugins' skills for the same job