A simple, keyboard-driven drum kit built with vanilla HTML, CSS, and JavaScript.
Press letter keys (A, S, D, F, G, H, J, K, L) to trigger different drum sounds — just like a real drum pad 🎹🥁
- A clear demonstration of core JavaScript fundamentals: DOM manipulation, event handling, audio playback, and CSS animation.
- Shows that I’m comfortable going to the browser “bare metal” — no frameworks, no abstractions.
- Serves as a baseline for sound UI/UX, timing, and interaction logic — useful even in modern React/TypeScript projects.
- Emphasizes clean, readable code and project structure, even for small-scale utilities.
- HTML — structure of drum keys
- CSS — layout and animations for key-press feedback
- JavaScript (vanilla) — event listeners, audio playback logic, UI state updates
No build system, no dependencies — just plain JS and browser APIs.
- Listens for
keydownevents viawindow.addEventListener - For each key event, checks for a mapped
data-keyattribute on both the visual key element and its corresponding audio element - If a match is found:
- Resets audio playback time to allow rapid repeated hits
- Plays the audio
- Triggers a visual animation on the key (e.g. a brief “pressed” effect)
- On
transitionend(or after a short timeout), removes the animation class so keys return to normal
This simple pattern demonstrates handling of real-time user input, managing UI feedback, and working with native browser APIs — skills relevant in any frontend context.
- Clone or download the repo
- Open
index.htmlin a browser (Chrome, Firefox, Safari — anything modern) - Press the keys: A S D F G H J K L and enjoy the drum sounds!
No build step or local server required.
js-drum-kit/
├── index.html # Layout and key elements
├── style.css # Styling and key animations
├── index.js # Core JS logic: event handling & audio playback
└── sounds/ # Drum sound files mapped via data-key