If you are new to Microsoft MakeCode, you can learn the basics of MakeCode here.
To add keyboard support, MakeCode needs to load an extension - bring in some blocks not in the main program. Click on the ADVANCED blog group:
Then click on the EXTENSION block:
And select the keyboard - Keyboard emulation over HID extension:
This adds a new block group on the main MakeCode page called KEYBOARD with several new functional blocks when you click the group button:
At this point you will want to define some action that lets your program know you wish to use one of the Keyboard functions. This can be anything but for example you may want to trigger keyboard input on:
- Press of the A or B buttons or the slide switch
- Press of a capacitive touch pad (marked A1 to A7)
- On a loud sound, shake of the board, or bright light
- Periodically send a key after several seconds, minutes, hours, etc.
For a simple demonstration, here are two button event blocks from the INPUT block group
on button click - the A button on Circuit Playground Express prints ABC as text, it can be any text you want to type with only a button press. If Button B is pressed, if you have a music app playing it will pause playing - it works for sure if you have iTunes or Spotify, but not all apps listen for the media key.
Feel free to define other actions and have fun with your new keyboard!
Do I have to unplug my other keyboard?
No, all modern operating systems allow more than one keyboard to be connected at a time.
How can I see the Circuit Playground Express as a device?
For Windows, open up the Control Panel application, go to Devices and Printers then look under the Devices group for a keyboard icon labeled "PXT Device":