Video: Dance Party - Events

Hour of Code | Dance Party: Events

My name is Erin, and I am a software engineer here at Code.org, and I helped build Dance Party.

To make different dance moves happen at just the right time with the music, you can use something called events. An event tells your program to "listen" for something to happen and then react right away.

Some examples of events are listening for a mouse click, an arrow button, or a tap on the screen.

Here we’re going to program a dancer to perform a move when you press the arrow buttons on the screen, or the keys on your keyboard.

We can use the "when up arrow" event block and connect a "do once" block to it. When someone press the up arrow key, the code attached to the "when up arrow" block is run. Which dance move will you choose?

Make sure the type of dancer you choose matches one of the dancers you created inside the "setup" block, or you might not see anything happen.

Eventually, you can create more events like this to make your dancers perform different moves with each key. Give it a try, and with a few lines of code you can make your own interactive dance.