Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Keyboard Shortcuts Task List Block for React

A task list driven by single keys while a row has focus: j and k move, x ticks, e edits the title in place, Backspace deletes with Undo, n jumps to the add field and ? shows the legend, with each key read back.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Give power users a task list they can run without the mouse, with this keyboard shortcut to-do list block for React with Base UI. A hairline frame with a plus mark on each corner holds an add field with the only Shine Button, a list of seven tasks, a foot, and a legend. Each task is one button that ticks it, with a roving tab stop so Tab enters the list once. While focus is on a row, j or Down and k or Up move along the rows, x ticks, e swaps the title for an Input (Enter saves, Escape cancels), Backspace deletes with a one-line Undo, n jumps to the add field and ? shows or hides the legend. The polite line under the list reads each key back ("Last key: j. On 'Pay the water bill', 4 of 7."). The legend is a list of Kbd keys that a Switch shows or folds. For planners, backlog tools and anything people live in all day.

FAQ

Where do the keys work?

Only while focus is on a task row. The listener sits on the list band, not on the window, and ignores keys with Ctrl, Cmd or Alt held and keys pressed in a field, so typing a task never triggers a shortcut and the site's own keys are untouched. Single letters are fine here because they only act inside the list; an app with global single-key shortcuts should let people turn them off.

How does editing in place work?

e (or the pencil on a row) swaps that row's title for an input holding the current text, with focus in it. Enter saves it, Escape puts the old title back, and Save and Cancel buttons do the same for a pointer. An empty title is refused with a message. Focus returns to the row after either exit.

Why is each row a single button?

It gives the list one tab stop and the right semantics: the row is a toggle button named by its title and pressed when done, aria-current marks the active row, and Enter and Space tick it natively. The checkbox inside is only a drawing of that state, so it is hidden and inert. The edit and delete icons beside it are for pointer and touch; keyboard users have e and Backspace.

How does Undo work?

Backspace removes the task, moves the active row to its neighbour and shows one line, "Deleted 'x'", with an Undo button that puts the task back at the same position. If you delete the last task, an empty state takes the list's place and focus goes to the add field.

What stays local, and how do I save for real?

The list resets on reload. In your app write each change from the keyed steps and the handlers (add, saveEdit, undo) to your store. The key map is one small function, keyed, so a different set of keys is a short edit, and the legend reads from KEYS.