DEMO: An event is a block of code that has a specific task and must receive a signal to run.

We use an event handler to tell the program what signal to listen for and what event to run.

  • Click Run to see the parts of an event.
  • Follow the onstage directions to see what each line does.
  • Click Submit and Next to answer the questions about functions.

To navigate the page using the TAB key, first press ESC to exit the code editor.

sprite = codesters.Sprite("superhero2") def space_bar(): sprite.move_up(100) stage.wait(.1) sprite.move_down(100) stage.event_key("space", space_bar)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)