Skip to main content
Public

Share visualization

Loading preview…

Fork of Blank Slate with Hot Reloading

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Fork of Blank Slate with Hot Reloading

1
NNita
Last edited Feb 25, 2025
Created on Feb 24, 2025

This interactive rectangle piano renders a 14-key keyboard with white and black keys using raw HTML, CSS, and JavaScript, without relying on external libraries. The visualization demonstrates DOM manipulation and event handling, as clicking each key triggers a Web Audio API `AudioContext` oscillator that plays a sine wave at a frequency mapped from a MIDI note number. The interface provides visual feedback by darkening keys on mousedown, and uses absolute positioning with a repeating seven-key pattern to place notes. The gradient background, responsive layout, and key styling are all achieved through inline styles and CSS.

AI-generated description

Interactive Rectangle Piano

This project creates a simple interactive piano using HTML and JavaScript. The piano features:

  • 14 white keys and black keys arranged in a standard piano pattern
  • Click interaction that produces different pitches
  • Simple UI with a responsive design

How to Use

  1. Click on any key (white or black) to hear a sound
  2. The piano follows the standard musical keyboard layout
  3. Keys have visual feedback when pressed

How It Works

The piano is built entirely with HTML and JavaScript:

  • White keys are created as white rectangles with borders
  • Black keys are positioned on top of white keys
  • Sound is generated using the Web Audio API
  • Each key is mapped to a specific note frequency

Implementation Details

The code uses:

  • CSS for styling and positioning the piano keys
  • Event listeners for interaction
  • Web Audio API for sound generation
  • Responsive design principles

This example demonstrates DOM manipulation, event handling, and basic audio synthesis in a web application.

Comments

Sign in to join the discussion.

MIT Licensed