| 1234567891011121314151617181920212223242526272829303132333435 |
- import board
- import terminalio
- from adafruit_display_text import label
- from keyboard import Keyboard
-
- # GUIDE
- # type freely! CTRL+D clears the text.
- # backspace, space, and return function as expected.
- # keys not recognised WILL print "UNKNOWN 0x??", but this is useful for extra key scans
- ######
-
- keyb = Keyboard()
-
- text = "Press CTRL+D to clear text\n\n"
- text_area = label.Label(terminalio.FONT, text=text)
- text_area.x = 10
- text_area.y = 10
- board.DISPLAY.root_group = text_area
-
- while True:
- key = keyb.scan()
- if key == "BACKSP":
- text = text[:-1]
- elif key == "CTRLD":
- text = "Press CTRL+D to clear text\n\n"
- else:
- ## WRAPPING
- ## calculate wrapping when entering a character
- lines = text.split("\n")
- current_line = lines[len(lines)-1]
- if len(current_line) > 35:
- text=text+"\n" # <- start a new line here
- ##############################################
- text = text+key
- text_area.text = text
|