pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Face Keyboard

案例程序

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)

功能说明

faces_keyboard.isNewKeyPress()
  • 检测是否有新的按键按下:
    • True:新的按键按下
    • False:无新的按键按下
faces_keyboard.readKey()
  • 读取输入按键key值
faces_keyboard.readStr()
  • 读取输入字符串。将会积累连续输入的内容。
faces_keyboard.deleteStrLast()
  • 删除输入的最后一个字符
faces_keyboard.clearStr()
  • 清空输入的字符
On This Page