HAT-022 Touch Piano
Instance declaration
When you add a HAT-022 Touch Piano block to the workspace, the following instance declaration is automatically inserted into the Python code:
python
cheesestick = CheeseStick(0)
hat022 = cheesestick.HAT022()Parameters
| Name | Kind | Description | Range / Type | Default |
|---|---|---|---|---|
| index | Dropdown option | Instance number (starting from 0) | Integer 0 or greater | 0 |
Start the touch piano
Uses the touch piano.

Parameters
(none)
Python
python
cheesestick = CheeseStick(0)
hat022 = cheesestick.HAT022()
hat022.start()Key input value
The input state of the selected key
It outputs 1 if the key is pressed, and 0 if the key is not pressed.

Parameters
| Name | Kind | Description | Range / Type | Default |
|---|---|---|---|---|
| unit | Dropdown option | Note key | Do (C), Do# (C#), Re (D), Re# (D#), Mi (E), Fa (F), Fa# (F#), Sol (G), Sol# (G#), La (A), La# (A#), Si (B), ◀ (left), ▶ (right), fn (fn) | - |
Python
python
cheesestick = CheeseStick(0)
hat022 = cheesestick.HAT022()
hat022.key_input('C')Is the key pressed?
Whether the selected key was clicked

Parameters
| Name | Kind | Description | Range / Type | Default |
|---|---|---|---|---|
| unit | Dropdown option | Note key | Do (C), Do# (C#), Re (D), Re# (D#), Mi (E), Fa (F), Fa# (F#), Sol (G), Sol# (G#), La (A), La# (A#), Si (B), ◀ (left), ▶ (right), fn (fn) | - |
Python
python
cheesestick = CheeseStick(0)
hat022 = cheesestick.HAT022()
hat022.key_pressed('C')