English
English
简体中文
日本語

UiFlow Tutorial

UiFlow1 Development Guide

Project Management

Use LTE network

UiFlow1 Blockly

Event

Unit

Faces Keyboard

Example

Read and print the key values and input strings

from m5stack import *
from m5ui import *
from uiflow import *
import face

setScreenColor(0x222222)

faces_keyboard = face.get(face.KEYBOARD)

def buttonA_wasPressed():
  # global params
  faces_keyboard.clearStr()
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  # global params
  faces_keyboard.deleteStrLast()
  pass
btnB.wasPressed(buttonB_wasPressed)


while True:
  if faces_keyboard.isNewKeyPress():
    print((str('Button value:') + str((faces_keyboard.readKey()))))
    print((str('Input string:') + str((faces_keyboard.readStr()))))
  wait_ms(2)

API

faces_keyboard.isNewKeyPress()
  • Detects if a new key is pressed:
    • True:New button pressed
    • False:No new buttons pressed
faces_keyboard.readKey()
  • Read the input key value
faces_keyboard.readStr()
  • Reads the input string. Successive inputs will be accumulated.
faces_keyboard.deleteStrLast()
  • Delete the last character entered
faces_keyboard.clearStr()
  • Clear the entered string
Page Tools
PDF
On This Page