Lesson 13: Other Forms of Input

Game Lab


In this lesson students continue to explore ways to use conditional statements to take user input. In addition to the simple keyDown() command learned yesterday, students will learn about several other keyboard input commands as well as ways to take mouse input.


Students have learned how to make simple decisions with conditionals. Sometimes however we want to make decision based on if the condition we asked about originally was false or we want to make a decision based on multiple conditions being true. Thats where else statements and more complex conditionals come in. Else statements are a second statement which is attached to a if statement. Else statements execute when the if statement it is attached to is false. You can think of it as “if something is true do thing 1 else do thing 2.

This concept is introduced alongside several new key and mouse input commands, allowing students to gradually build up programs that input in different ways.


Students will be able to:

  • Use an if-else statement to control the flow of a program.
  • Respond to a variety of types of user input.


  • Conditionals – Statements that only run under certain conditions.

Introduced Code

Warm Up (5 minutes)

Check for Understanding

Today we’ll be picking up today where we left off yesterday – using conditionals to write programs that respond to user input. Let’s refresh what we learned yesterday.


  • What is a Boolean? (eg. a true/false value)
  • What is the relationship between a Boolean and a Conditional? (eg. a conditional asks a Boolean question and runs code if the answer is true)
  • What are some examples of comparison operators that result in a Boolean? (eg. >, <, ==)
  • What is the difference between = and ==? (eg. = is used to assign a value, == is used to check if two values are equal)

Today we’re going to look at a wayto make our conditionals even more powerful, and see some new ways to get user input.

Activity (40 minutes)

If/Else and More Input

Transition: Move the class to Code Studio, and have students complete the prediction level as a class or in small groups, then talk about what they found.

Video: Watch the video as a class and review the discussion questions together.

 Code Studio levels

  • Lesson Overview
  • Predict
  • Video: If/Else Statements

Discussion Goals

Make sure students are thinking of situations in which they want two different things to happen, depending on the situation. For example, they may say that they want one animation if the sprite is moving to the left and a different animation if the sprite is moving to the right. Challenge the students to think about when they would just use an if block, and when an ifelse block is necessary.

  • Input with If-Else
  • If-Else Statements
  • More Input

Wrap Up (5 minutes)

This discussion serves as a brief review and assessment of the new user input commands. As students share out, press them to explain why their choice is better than other, similar choices (mouseDown / mouseWentDown / mouseWentUp). If any commands are missing after all the groups have shared out, elicit the missing ones from the group before moving on.

Prompt: You now have many different ways to detect user input. With a partner, choose three difference user input commands and think of an example of when you might use them. Be ready to share with the class!


Distribute: Give each student a copy of the peer review guide.

Students should spend 15 minutes reviewing the other student’s card and filling out the peer review guide.

Iterate – Update Code

Circulate: Students should complete the peer review guide’s back side and decide how to respond to the feedback they were given. They should then use that feedback to improve their cards.


Using the rubric, students should assess their own project before submitting it.

 Send students to Code Studio to complete their reflection on their attitudes toward computer science. Although their answers are anonymous, the aggregated data will be available to you once at least five students have completed the survey.

Wrap Up (10 minutes)

Sharing Cards

Goal: Students share their creations with the class.

Share: Find a way for students to share their cards with each other, and with the intended recipient. It will likely be helpful to use the share link for the project so that students can share the project with other students.

Leave a Reply

Your email address will not be published. Required fields are marked *