1
0

test_keyboard.py 343 B

123456789101112
  1. from nicegui import ui
  2. from nicegui.testing import Screen
  3. def test_keyboard(screen: Screen):
  4. result = ui.label()
  5. ui.keyboard(on_key=lambda e: result.set_text(f'{e.key, e.action}'))
  6. screen.open('/')
  7. screen.wait(1.0)
  8. screen.type('t')
  9. screen.should_contain('t, KeyboardAction(keydown=False, keyup=True, repeat=False)')