Button Events in MakeCode Arcade

Kiki Prottsman
Kiki’s Corner
Published in
2 min readJul 25, 2022
A clicker game that uses the `on button A pressed` event

What is a button event?

In MakeCode Arcade, a button event is any event that runs in response to the specific state of a button. For example, if you want to shoot a star projectile every time you press the A button, a button event will help you make that happen.

What can I use button events for?

You can use button events for anything that’s meant to be triggered manually by the user. This could mean throwing a projectile, changing an image, initiating a conversation, or launching a function.

How can I use button events?

In Arcade, button events can be programmed for the press of a button, the release of a button, or the repeated press (hold) of a button.

You can use more than just the A and B buttons, as well. Arcade gives you the option to use the up, down, left, or right buttons on the D-pad, as well as the menu button.

To create button event code, drag the on [A] button [pressed]

block out into the workspace and choose which button you want to set a listener for and which action is desired (pressed, released, or repeat).

Next, add the code inside of this event that will run the actions that you want to associate with the button event. The code inside will run in order each time that event occurs!

Every time the (A) button is pressed, this code will change the image of the mouse, increase the size of mySprite, and add a point to the first player’s score

And that’s all there really is to it!

Which button event do you find yourself using the most in Microsoft MakeCode Arcade? Leave a comment below and let me know!

--

--

Kiki Prottsman
Kiki’s Corner

Kiki is an author, educator, and the Director of Education for Microsoft MakeCode