I have a lot of boards and usually need to re-use code even for different projects.

full_display_test.py 637B

12345678910111213141516171819202122232425262728
  1. import board
  2. import terminalio
  3. from adafruit_display_text import label
  4. from keyboard import Keyboard
  5. # GUIDE
  6. # type freely! CTRL+D clears the text.
  7. # backspace, space, and return function as expected.
  8. # keys not recognised WILL print "UNKNOWN 0x??", but this is useful for extra key scans
  9. ######
  10. keyb = Keyboard()
  11. text = ""
  12. text_area = label.Label(terminalio.FONT, text=text)
  13. text_area.x = 10
  14. text_area.y = 10
  15. board.DISPLAY.root_group = text_area
  16. while True:
  17. key = keyb.scan()
  18. if key == "BACKSP":
  19. text = text[:-1]
  20. elif key == "CTRLD":
  21. text = ""
  22. else:
  23. text = text+key
  24. text_area.text = text