Category:Events

Triggers a sequence of blocks to run when a specified key is pressed.

Sometimes code should only be run if an event happens. In this case, when a specified key on the keyboard is pressed, the blocks attached under the event block will begin to run sequentially.

This block has a drop-down menu with “when” and “while” options. “When” a key is pressed, the code will only run once. “While” a key is pressed, the code will run over and over again until the key stops being pressed.

Parameters

NameDescription
when/while Determines if the code is run when the key is pressed (runs once at a time) or continuously while the key is pressed
key Which key triggers the event

Found a bug in the documentation? Let us know at documentation@code.org