Lab/09
Keycap Visualizer
Key events are matched by physical key code, so the layout stays honest. Chords light up together. On touch, tap the keys.
- Interaction
- Keyboard
Type or tap a key
lab/keycaps-last key
0presses
Installation
Add Keycaps to your project with the shadcn CLI. The files land in components/lab, ready to edit.
$ pnpm dlx shadcn@latest add @soultel/lab-keycapsOr by URL: https://asafefe.dev/r/lab-keycaps.json
Brings along
- utils
Usage
import { Keycaps } from "@/components/lab/keycaps"
export function Example() {
return <Keycaps onPress={(code, label) => console.log(code, label)} />
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| rows | Keycap[][] | QWERTY | Rows of { code, label, wide? }, matched by KeyboardEvent.code. |
| onPress | (code: string, label: string) => void | - | Called once per press, not on auto-repeat. |
| listen | boolean | true | Listen to the physical keyboard. Inputs are ignored. |
| keyClassName | string | - | Classes for every key. |
