Keyboard

Interactive on-screen keyboard with themes, layouts, and press animations.

Keyboard renders a full on-screen keyboard in React that lights up keys as your visitor types on their physical keyboard. Multiple themes and layouts ship as props, and every key press animates so the component doubles as a live typing display. Built with React and Tailwind CSS. Useful for shortcut documentation pages, typing practice apps, kiosk interfaces, and product screenshots that need a believable keyboard.

Installation

Examples

Usage

import { Keyboard } from "@/components/ui/keyboard";
// Basic usage with default cyberpunk theme
<Keyboard />
 
// Custom theme with different layout
<Keyboard
  theme="retro"
  layout="compact"
  showFunctionKeys={false}
/>
 
// Active keys highlighting
<Keyboard
  activeKeys={["KeyW", "KeyA", "KeyS", "KeyD"]}
  activeKeyGlowColor="#ff5555"
  activeKeyGlowIntensity={0.9}
/>
 
// Custom styling and event handlers
<Keyboard
  theme="neon"
  keyColor="#1a1a2e"
  keyTextColor="#e6e6e6"
  accentColor="#ff2a6d"
  onKeyPress={(code, key) => console.log(`Pressed: ${code}, ${key}`)}
  onKeyRelease={(code, key) => console.log(`Released: ${code}, ${key}`)}
/>

Props

PropTypeDefaultDescription
layoutstring"standard"Keyboard layout (standard or compact)
showFunctionKeysbooleantrueShow function keys (F1-F12) row
showNavigationClusterbooleantrueShow navigation key cluster
activeKeysstring[][]Array of key codes to highlight as active
activeKeyGlowColorstring"#F57644"Glow color for active keys
activeKeyGlowIntensitynumber0.8Intensity of glow effect for active keys (0-1)
themestring"cyberpunk"Keyboard theme (cyberpunk, retro, neon, pastel)
keyColorstring"#2a2a2a"Base color for keyboard keys
keyTextColorstring"#ffffff"Text color for keyboard keys
accentColorstring"#F57644"Accent color for special keys and highlights
keyPressedColorstring"#333333"Color for pressed keys
keyPressAnimationDurationnumber150Duration of key press animation in milliseconds
onKeyPressfunction() => {}Callback function when a key is pressed (code: string, key?: string) => void
onKeyReleasefunction() => {}Callback function when a key is released (code: string, key?: string) => void
classNamestring""Additional CSS classes to apply
allowPhysicalKeyboardbooleantrueAllow physical keyboard integration
perspectivenumber1000CSS perspective value for 3D effect
rotateXnumber0X-axis rotation angle in degrees