Keyboard

A customizable interactive keyboard component with various themes, layouts, and animation options.

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