8000 Keyboard support for drawing and acting on cards by noahm · Pull Request #663 · noahm/DDRCardDraw · GitHub
[go: up one dir, main page]

Skip to content

Keyboard support for drawing and acting on cards - #663

Open
noahm wants to merge 4 commits into
claude/mantine-ui-migration-sju0b6from
claude/keyboard-navigation-eval-j1c4jy
Open

noahm wants to merge 4 commits into
claude/mantine-ui-migration-sju0b6from
claude/keyboard-navigation-eval-j1c4jy

Conversation

@noahm
@noahm noahm commented Sep 24, 2026
Copy link
Copy Markdown
Owner

Stacked on #627 (Blueprint → Mantine). Merge that first, or retarget this PR once it lands.

Makes the full loop of drawing and then protecting, vetoing, pocket picking and picking winners work from the keyboard.

Cards

  • Cards can be reached with Tab and act as buttons (role="button", aria-haspopup="menu"). They have a :focus-visible ring outside the card's colored border, so mouse clicks don't show it.
  • Enter / Space opens the action menu with focus on the first item. Mantine's Menu handles the rest: arrow keys, ArrowRight into the player submenu, Escape.
  • 1–9 open the same menu for the player at that position in display order. The menu is headed "As P1", and protect, pocket pick, veto and winner apply to that player directly with no submenu. On an empty pick slot, only "Pick as P1" is offered. A number past the last player does nothing.
  • Opening a menu with the mouse works as before: Mantine's focus placeholder is kept, so no item looks selected.

Focus after actions

  • After an action, focus returns to the card. That includes vetoes. A veto re-sorts the set and removes the menu's items before Mantine can hand focus back, which used to drop focus to <body>.
  • A redraw or a hidden veto removes the card, so focus goes to the card now in its position in the set.
  • Pocket-pick search and removing a label also return focus to the card. The song search Modal now has returnFocus={false}, because the element it would return to is the menu item, which no longer exists.

Arrow keys between cards (src/utils/card-nav.ts)

  • ← → move through the cards of one set (data-card-group) in order and stop at the ends.
  • ↑ ↓ move by screen position: to the nearest card in the row above or below. That covers wrapped rows, extra sets in the same match, and older draws.
  • ↑ from the top row focuses Draw!. ↓ from a header button returns to the last card you were on.
  • The same keys work in the Eligible Charts grid.

New draws

  • N opens the New Draw dialog. It's ignored in text fields, other dialogs and menus, and when no config exists yet.
  • Focus starts in the title field, the form is now a real <form> so Enter submits, and focus lands on the new draw's first card. Cancelling returns focus to Draw!. The form used to edit an existing match's details also submits on Enter.
  • Enter in the payout field calls preventDefault, so confirming the field doesn't also submit the form with the old value.
  • The settings button is now ActionIcon component={Link}: one Tab stop instead of two.

Testing

  • oxlint, oxfmt --check and tsc --noemit are clean.
  • I drove classic mode keyboard-only in headless Chromium: N → title → Enter; arrow keys across sets, into the header and back; protect, veto, redraw, pocket pick and label removal, both from the menu and with number keys; plus a second run with "hide vetoes" on. A separate mouse-only run confirmed no focus ring and no item highlighted.
  • Event mode wasn't tested in a browser (it needs partykit running). It uses the same components.

🤖 Generated with Claude Code

https://claude.ai/code/session_01By1tH8wfYsnJBCtF3FJdhw


Generated by Claude Code

Cards are now focusable buttons with a visible focus ring. Enter or Space
opens a card's action menu with focus on its first item (arrows, ArrowRight
into the player submenu, Escape all come from Mantine's Menu). Focus comes
back to the card after an action, including when a veto re-sorts the set,
and passes to the card in the same slot when a redraw replaces the card or
a hidden veto removes it. Pocket-pick search and label removal return
focus to the card too.

Arrow keys move between cards: left/right within a set, up/down to the
nearest card in the row above or below (across sets and older draws), and
up from the top row into the header. Arrow down from the header's buttons
returns to the last focused card.

New draws: N opens the draw dialog, focus starts in the title field, Enter
submits, and focus lands on the new draw's first card. The settings link
is a single tab stop now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01By1tH8wfYsnJBCtF3FJdhw
A number key on a focused card opens its action menu like Enter does, but
for the player at that position in display order. The menu is headed
"As <player>" and protect, pocket pick, veto and winner act for that player
directly instead of opening the player submenu; an empty placeholder only
offers the pick to that player. Numbers past the last player do nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01By1tH8wfYsnJBCtF3FJdhw
@vercel
vercel Bot commented Sep 24, 2026 •
Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ddr-tools Ready Ready Preview Sep 24, 2026 2:38am UTC

Adds a Button Mapping section under Global Settings > This Browser Only.
Each of two sides binds keys to up/down/left/right, a green accept and a
red back button. Accept can either open a card's menu like Enter, or act
for a chosen player like the 1-9 keys. Bindings are stored by
KeyboardEvent.code in localStorage (ddrtools.keymap), for every event.

A window capture listener takes over mapped keys before anything else
sees them, so a key bound to a button stops doing its default job (N no
longer opens a draw, a digit no longer opens a card menu). It dispatches
the matching synthetic arrow, Enter or Escape at the focused element for
the existing handlers, and fills in the defaults synthetic events lack:
accept clicks buttons and submits forms, and an unhandled direction moves
through the tab order of the current dialog or header. With nothing
focused, the first press lands on a card or the Draw button. A key bound
to its own native function (the real down arrow as Down) is left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01By1tH8wfYsnJBCtF3FJdhw
Each panel button can now also have a gamepad input bound: a button, or a
stick/d-pad axis pushed past halfway in one direction. Pads are told apart
by their index, so a cabinet whose two sides show up as two gamepads can
bind each side to its own pad. The binding UI takes whichever comes first,
a key or a pad input (an input already held when binding starts has to be
released first), and a button can have one of each.

A polling loop (running only while a pad is connected) fires the bound
button when its input goes down, and repeats held directions after 400ms
every 120ms. An input only ever fires on a fresh press, so one bound while
held doesn't go off the moment binding ends.

The button actions move out of keymap-listener into panel-actions, shared
by the key and pad listeners.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01By1tH8wfYsnJBCtF3FJdhw

This branch was successfully deployed

1 active deployment
Preview — 66b7d5ae Deployed Sep 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0