Introduction to Control
The Control feature in Microsoft MakeCode provides essential runtime and event utilities that allow developers to manage the flow of their programs effectively. This includes functionalities such as running code in the background, resetting the program, and handling events.
Key Features:
- Background Execution: Use
control.inBackground()to run tasks without interrupting the main program flow. - Reset Functionality: Easily reset your program state with
control.reset(). - Event Handling: Manage events with
control.onEvent()to respond to user inputs or other triggers. - Timing Utilities: Utilize
control.waitMicros()for precise timing control in your applications. - Event Metadata: Access event details using
control.eventTimestamp()andcontrol.eventValue()for better event management.
Use Cases:
- Game Development: Implement background tasks for game mechanics while keeping the main game loop responsive.
- Interactive Applications: Create responsive applications that react to user inputs and events seamlessly.
- Educational Tools: Develop educational programs that require precise timing and event handling for interactive learning experiences.

