Skip to content
Discussion options

You must be logged in to vote

You can handle global keyboard events with the page.on_keyboard_event callback, see the docs here: https://flet.dev/docs/guides/python/keyboard-shortcuts/

If you want the keyboard event to only work if the TextField is highlighted you'll have to add a variable that is set to True with the on_focus callback of your TextField and set to False with the on_blur callback of your TextField. The you can check that the variable is set before running your program, see the docs here: https://flet.dev/docs/controls/textfield/#on_focus

text_field_in_focus = False

def on_focus_callback(_):
    global text_field_in_focus
    text_field_in_focus = True

def on_blur_callback(_):
    global text_field_in…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@plugeit
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by plugeit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants