You can mix Blocks & Python! (Patreon)
Published:
2023-12-22 19:16:34
Imported:
2026-06
Content
A teacher recently asked if SPIKE can read the computer keyboard for extra interactivity in their programs. While we don't have a dedicated block yet, you can easily do it in Python.
So... you can write a Python function and just call it from your block program! The possibilities are really endless if you think about it.
In this example, we wrote a helper script in Python that gets input from the keyboard. Once you do that, you can import it in your block project as shown above.
And naturally, Technic, City, MINDSTORMS, and Boost can do the same when you use Pybricks. Why would you want that? Well... to build this!