Project 465: Merry Months

6. Switch between pages with code

We've got two different backdrops already, but there's no way to actually flip through the calendar yet! We're going to use Events to get the flipping to work. Events are pieces of code that wait for one thing to happen so they can tell another thing to happen. We want code that waits for a key on the keyboard to get pressed and then tells the backdrop to switch.
Starting point file for this challenge

Your goal

Steps

1. Add an event that checks for key presses

Do you know what code lets us know when a key on the keyboard is pressed? All Event code lives in the yellow Events section and has bumps on top. That's how you know it's an event code block. Find the block that says "when ____ key pressed" and drag it into your workspace. If you're having trouble, make sure you click on the code tab first. 

2. Make the event check for right arrow key presses

The "when key ____ pressed" always starts out looking for "space" key presses. What key do you think we should look for if we're trying to move forward in the calendar? Let's try using the right arrow key. Click on the word "space" in the "when key ___ pressed" block and change it to "right arrow". 

3. Switch to the next backdrop when the right arrow key is pressed

Now, we can add code that runs when the event happens. Here, we want code that switches to the next backdrop. Find a block in the dark purple Looks section called "next backdrop". This code just switches to the next backdrop in the list.