This project will teach you how to create a piano in Scratch


Duration: 8-10 mins

Level: Beginner

Programming Language: Block-based programming


What you will need:

  1. An account in Scratch (sign up here)
  2. A laptop/desktop


Part 1: Design

Our end goal is to create 8 rectangles that will represent the piano keys like the picture below.

Each shape is a sprite, to create one, hover over the the cat logo on the bottom right corner of the screen and press

1. Paint

This will direct you to the costumes tab of the Sprite where you can draw whatever you want, for this project, we want to draw a rectangle.

  1. Choose the color you want inside of the rectangle to be
  2. Choose the color of the outline of the shape
  3. Click on the Square shape to easily draw the rectangle
  4. Use the second pointer button to resize the shape.

Once you’re done with the first shape, you can easily make the remaining 7 shapes by

  1. Right clicking on your mouse and pressing DUPLICATE
  2. You can then change the color of the shape

Part 2: Code

Once you have all 8 sprites, you can move one to code each sprite one by one. To find the piano sound,

  1. Go to CODE tab
  2. Click on the bottom left corner to find the music extension
  3. Click on music to get instrument sounds


Each sprite will have a similar set of codes.

  1. Click on the sprite you want to add the codes to
  2. Go to events and look for the block “when 1 key pressed“ (this will be the trigger)
  3. Go to music and drag the block “play note 60 for 0.5 beats“ underneath the event block


Continue with the rest of the sprites with the code in the picture below


You can also watch and code along with our instructor here and you can also pin it below!