Desk accessories · component · 16K

Keyboard Viewer

An on-screen keyboard in the spirit of the Key Caps desk accessory: a compact ANSI keyboard with square keycaps that invert while the physical keys are held, Shift and Option layers, a text field that shows what you type, and highlighted shortcuts.

Listens on window keydown/keyup by KeyboardEvent.code only while mounted and listening (default true). highlight={["⌘K", { keys: "⇧⌘P", label: "Command palette" }]} marks keys with a heavy frame and lists the shortcuts as text; the drawn keyboard itself is aria-hidden. With typeAnywhere (default) keys typed while nothing else has focus go into the field. Legends follow a US layout; override any of them per layer through layout.

Install

pnpm dlx shadcn@latest add @s7ui/keyboard-viewer

Example

This example also uses @s7ui/window.

Shortcuts:
  • Command KSearch
  • Shift Command PCommand palette

Info

Files:
components/retro/keyboard-viewer.tsx
Uses:
@s7ui/theme, @s7ui/bitmap, @s7ui/input, @s7ui/modifier-glyphs
Packages:
—