Introduction: Scratch Month: Coding Makey Makey Key Presses for IPad

About: Computers are going bananas! Use #makeymakey to practice invention literacy and connect the world to your computer.

Today you will code key presses in Scratch, so head to Scratch and create a project along with us!

Choose you own characters and backdrops and let's get started!

If you have not used Scratch with Makey Makey before, the video below is designed as a create-along project to help you get started.

Try following along with the video to code key presses in Scratch. The rest of this class will focus on specific areas of Scratch to help you learn how to create your own game with ease! Scratch was created at MIT and both of our inventors (Jay and Eric) were actually on the Scratch team! Scratch is a free online coding playground where you can create your own stories, games, and animations with coding blocks.

You can now code key presses in Scratch and plug directly into your iPad to play! (See adapters we've tried here.)

Supplies

Step 1: Getting Familiar With Scratch Work Area

If it is your first time to look at Scratch, take a moment to look at how everything is laid out. It has code blocks on the left, each grouped by color in palettes for the different things you will want to use to control your sprites: motion, looks, sound, events, control, sensing, operators, variables, and my blocks (where you can create your own blocks.)

To make your sprite (that's what we call a character in your game) do something, you will drag coding blocks to your work area in the center. You can drag a block to the center and then click on it to see what happens to the sprite on the right side. Try dragging the "move 10 steps" block to the work area and then click on it. It will make Scratch cat move, but to have this happen when you press a key press, you'll want to use a hat block to trigger the event. Head to the "Events" palette and try dragging a "When this sprite clicked" block to your work area. Snap the stacking block under the hat block and now you can make Scratch cat move when you click on it.

To use Scratch on an iPad, just navigate to scratch.mit.edu in the browser and start coding!

Step 2: Add Makey Makey Extension

There are lots of ways to code key presses, but it's really quick and easy to add the Makey Makey extension so you know when you are coding with a hat block that will work with your Makey Makey! Click the " extensions" block to access all extensions (like micro:bit, Makey Makey, music, etc.)

A hat block will start a script- think of it as a way to trigger something to happen in your project. Scratch works by connecting stacking blocks to hat blocks. The hat blocks trigger the stacking blocks which instruct the sprites in your project how to behave. There are tons of possibilities for creating online games, music, and inventing your own applications with Scratch! Things get even more fun when you add extensions to help you connect to real world things! If you have LEGO Mindstorms or a Micro:bit, you can add those extensions too (but they might not all work on an iPad.) All of your extensions will show up underneath the "My Blocks" palette. Extensions appear on the projects you've added them. So you have to add the extension you want to use on each new Scratch project.

Blocks inside the Makey Makey Extension

There are only two hat blocks in our extension. These hat blocks will trigger the stacking blocks you add underneath them and are triggered based on key presses. The first one will control what happens when you press one key on your keyboard. If you want to combine key presses to have a special effect, the other block is a "secret code" block with a few different key press options in the dropdown arrow.

Secret Codes in Scratch
Eric Rosenbaum made this block as a nod to a cheat code known as "The Konami Code." You can also use this extension to put secret codes in your game that add a bonus feature or use it as an integral part of your game. The "when pressed in order" block is based off of secret codes from 1980s Konami games, dubbed "the Konami Code."

↑ ↑ ↓ ↓ ← → ← →

Check out Eric Rosenbaum's Beatbox Quartet and see what happens when you enter the Konami Code!

Step 3: Adding Sounds

People love to use Makey Makey and Scratch to create custom sound effects! In fact, the piano app on our webpage is based on a Scratch piano!

To add more sounds to your project, click on the "Sounds" tab where you can choose a sound from the Scratch library, record your own sound, or upload a mp3 or wav file to use in your project. Once you add a sound, you can find it in the "play sound until done" or "start sound" blocks. Try adding both sound blocks to see how they are different.

Step 4: Create and Play

Create your own Scratch project and connect your Makey Makey! Share your creations with us!

To go further, check out these guides: