shadcn.io is not affiliated with official shadcn/ui
Kbd examples · Arrow Keys
WASD Gaming Keys Kbd for React
The W, A, S and D movement keys in an inverted T, as games lay them out.
Games on a computer move with W, A, S and D, so the other hand can stay on the mouse. This React example places W above A, S and D on a three-column grid, with an empty cell on either side, so the four Kbd caps take the same inverted T as the arrow keys.
Preview
Installation
FAQ
When should I show WASD instead of arrow keys?
For games and 3D or canvas views where the right hand uses the mouse. For interfaces and lists, show the arrow keys. Supporting both is common.
Why lay WASD out like the arrow keys?
The keys form the same shape on the keyboard, W above and A, S, D below, and the layout makes the mapping to up, left, down and right obvious.
How do WASD controls work on other keyboard layouts?
On AZERTY, the same positions are Z, Q, S and D. Read event.code (KeyW, KeyA…) instead of event.key: it names the physical position, so the controls work on any layout. Show the user's own letters if you can.
Should the hint include Space for jump?
If your game uses it, add a wide Space cap below the cluster. Keep the other keys, like Shift to run or E to interact, in a separate list so the movement cluster stays readable.
Related
- Arrow Keys Cross Pattern KbdFour arrow keys in the inverted T of a
- Arrow Keys Horizontal KbdLeft and right arrow keys grouped side by
- Vim Navigation Keys KbdThe H, J, K and L keys in one row, the
- Editing Keys KbdThe Home, End, PgUp and PgDn editing keys
- F1 Help Key KbdA single F1 key, the usual shortcut for
- F12 DevTools Key KbdA single F12 key, the shortcut that opens