> For the complete documentation index, see [llms.txt](https://resources.digitalmoment.org/micro-bit-data-and-climate-change/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://resources.digitalmoment.org/micro-bit-data-and-climate-change/our-tools/02-makecode/a-events.md).

# A - Events

![](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FianaV65NxD0QLg0SWcZW%2Fuploads%2FzikNL3Pa9nxgwbzHFKAq%2FScreen%20Shot%202022-05-17%20at%2011.07.25%20AM.png?alt=media\&token=4c21fe64-e5ec-4547-a37e-b555ca422a5b)

In this section, we are learning different ways for the micro:bit to receive commands, or as they are called in coding, **events**. Events enable the interaction between us and the device (micro:bit). Some equivalent events in our daily life are:

* **Pressing** a key on your keyboard
* Starting a car by **turning** a key or **pressing** a button
* **Saying** a command to enable your phone's digital assistant

The events we are exploring in the micro:bit are **on start**, **forever**, **on shake** and **on button A pressed**.​

<details>

<summary>Create a new project and clear the Workspace​</summary>

Create a new project by going to [makecode.microbit.org](https://makecode.microbit.org/) and deleting the current blocks (**on start** and **forever)** from the **Workspace** by dragging them to the **Block groups** area.

&#x20;                                   ![](/files/MiUyDcqDPGBQAsi618ai)

</details>

<details>

<summary>​Events blocks</summary>

We will code our micro:bit to display the word "Hi", using different events.  Go over the process and try to spot the differences and when would you choose one over the other

#### on start, forever, on shake and button A pressed

&#x20;                                        ![](/files/AEft7kGWfGINFedQWE2E)       &#x20;

* **on start** runs the code inside it as soon as the micro:bit is powered.  A very useful place to set up your application.
* **forever** executes the code inside it as long as the micro:bit is powered.  Forever, as long as the micro:bit is running.
* **shake** is lots of fun since it executes the code inside it when the user shakes the micro:bit.  This is possible as the micro:bit can detect acceleration.
* **on button A pressed** works just like your tv remote or the buttons on a game console.  The device detects a button being pressed and runs the code inside it.

</details>

{% hint style="info" %}
Did you notice that the **blocks** in the **Block groups** area are colour-coded? This makes it easy to look for blocks you see in the example activities.
{% endhint %}

We can trigger events with many different blocks in MakeCode as we saw in this section, but so far we only displayed text. In the next section, **B - Animations**, we are working with images.<br>
