Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome and WebView on Android does not support page.on_keyboard_event correctly #4824

Open
1 task done
skyhook88 opened this issue Feb 4, 2025 · 0 comments
Open
1 task done

Comments

@skyhook88
Copy link

Duplicate Check

Describe the bug

On Chrome and webview on Android when typing into a flet TextField page.on_keyboard_event the event does no provide the key information and instead comes through as : 'Unidentified'

KeyboardEvent(key='Unidentified', shift=False, ctrl=False, alt=False, meta=False, name='keyboard_event', data='{"key":"Unidentified","shift":false,"ctrl":false,"alt":false,"meta":false}')

with the same program and typing into the page itself (no controls with input focus) it comes through correctly eg:

KeyboardEvent(key='D', shift=False, ctrl=False, alt=False, meta=False, name='keyboard_event', data='{"key":"D","shift":false,"ctrl":false,"alt":false,"meta":false}')

using desktop chrome and other desktop browsers it works as expected with page.on_keyboard_event providing visablity to flet programs on the keys held down and pressed.

Code sample

Code
import flet as ft

def main(page: ft.Page):
    def on_keyboard(e: ft.KeyboardEvent):
       print(e)


    page.on_keyboard_event = on_keyboard
    page.add(
        ft.TextField()

    )

ft.app(main,host="0.0.0.0", port=8443,view=ft.AppView.WEB_BROWSER)

To reproduce

Open the web page on android chrome, select the TextField and type something on the android popup keyboard or an attached Bluetooth keyboard and the flet program will print a event with the key as "Unidentified" tap an area outside the TextField to remove input focus and the correct key is recorded in the event.

Do the same on chrome on desktop or other browser and it works for both cases.

Expected behavior

The behavior should allow for page.on_keyboard_event to provide visibility on the keys pressed anywhere within the page for all platforms.

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Android Chrome and webView

Flet version

Have tried and appears to be in v0.26.0 and v0.24.0 and likely all

Regression

No, it isn't

Suggestions

Based on what I can find online its a android chrome issue with it only supporting particular calls - I'm hoping that there is a tweak that can be made in the Flet internals to use an alternate call.

Here is the stack overflow thread that may help link to more context : https://stackoverflow.com/questions/59584061/why-is-unidentified-returned-on-keyboard-input-on-mobile

Logs

Logs
[Paste your logs here]

Additional details

Many thanks guys for this awesome project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant