Build Six Hold-to-Play Piano Keys with Vanilla Web APIs

Last updated: August 15, 2026

Quick Overview

The question asks the candidate to create a simple piano interface with six keys (C, D, E, F, G, A) using only vanilla HTML, CSS, and JavaScript, ensuring that the keys respond to both mouse and keyboard interactions.

Roblox
Software Engineering Fundamentals
Frontend Engineer
Roblox
August 15, 2026
Frontend Engineer
Technical Screen
Software Engineering Fundamentals
Medium

5

0

51 solved


The question asks the candidate to create a simple piano interface with six keys (C, D, E, F, G, A) using only vanilla HTML, CSS, and JavaScript, ensuring that the keys respond to both mouse and keyboard interactions.

This question is typically asked during the technical screen round to evaluate a candidate's proficiency in fundamental frontend development skills. The interviewer is looking for the candidate's ability to implement interactive UI components using core web technologies without relying on frameworks or libraries. This assesses both coding skills and understanding of event handling in web applications.

What the Interviewer Expects
  • Implement a responsive UI with HTML and CSS for the piano keys.
  • Use JavaScript to handle mouse and keyboard events effectively.
  • Ensure that the active state is visually represented when keys are pressed.
  • Demonstrate clean code practices and proper structuring of functions.
  • Handle edge cases, such as multiple keys being pressed simultaneously.
Key Topics to Cover
HTML/CSS
JavaScript Event Handling
DOM Manipulation
User Interaction
Responsive Design
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you extend this project to include sound playback?
  • What challenges did you face while implementing the key press functionality?
  • Can you explain how you would optimize this code for performance?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

The task is to create a piano interface with six keys that respond to user interactions. The keys should change their visual state when pressed (active) and revert back when released. The implementati...

High-Level Design

We will create a simple HTML structure for the piano keys, style them using CSS, and add interactivity with JavaScript. Each key will be represented as a div element, and we will use event listeners f...


Submit Your Answer
Markdown supported

Related Questions