Build a piano keys widget that responds to mouse and keyboard input.
Unlock detailed company stats for this questionUpgrade
Stack: vanilla HTML, CSS and JavaScript, no frameworks or libraries. You are given a row of six piano keys: C, D, E, F, G, A. A key should appear pressed the entire time it is held down and return to normal the instant it is released. 'Pressed' means the element has the CSS class active (the styling for .key.active is already written). Keys must respond to both mouse (press and hold on a key) and the physical keyboard (press and hold the matching letter: c, d, e, f, g, a).
Requirements:
- Holding the mouse down on a key adds
active; releasing removes it. - Holding the corresponding letter on the physical keyboard adds
active; releasing removes it. - Multiple keys can be active at once; holding c and e together lights up both.
- Keys not in the set (e.g. k, Enter, arrow keys) are ignored.
Format · Technical screening.
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
