Skip to content

[Android] TextBox.KeyDown event is not working #13983

Closed

Description

@Soap-141

Current behavior

The KeyDown event is not triggered on my Google Pixel 6. It may be working on Samsung devices.

Expected behavior

The KeyDown event should triggered on all devices.

How to reproduce it (as minimally and precisely as possible)

  1. Download TextBoxEvent.zip
  2. Add a breakpoint in the event handler
  3. Start project on Android
  4. Press key on virtual keyboard (Enter and others)
  5. Notice the event is not triggered

Workaround

N/A

Works on UWP/WinUI

None

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia, Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

Latest stable 4.10 because I haven't been able to build latest preview.

Affected platforms

Android

IDE

Visual Studio 2022

IDE version

Latest

Relevant plugins

N/A

Anything else we need to know?

N/A

Activity

  1. added
    kind/bug
    triage/untriaged
    difficulty/tbd
    on Oct 16, 2023
  2. jeromelaban commented on Oct 16, 2023

    @jeromelaban
    Member

    Thanks for the report. It is likely that the KeyDown event is not propagated (and may not be able to) because the native TextBox is handling it for itself.

    Is it something that worked before?

  3. Soap-141 commented on Oct 16, 2023

    @Soap-141
    Author

    @jeromelaban Yes it did, I can confirm it soon, I'll go back to a previous version of the project and tell you which Uno version it was. But if it's related to the device itself it might not work in previous versions either. I'll update you in 15 minutes.

  4. Soap-141 commented on Oct 16, 2023

    @Soap-141
    Author

    @jeromelaban Doesn't work anymore on previous version, looks like it's the device. I was able to reproduce on Pixel 3 emulators too. Might be a Pixel thing.

  5. added
    kind/regression
    and removed
    kind/bug
    on Oct 17, 2023
  6. self-assigned this
    on Oct 25, 2023
  7. changed the title [-][Android] TextBox KeyDown event is not working[/-] [+][Android] `TextBox.KeyDown` event is not working[/+] on Oct 25, 2023
  8. added
    project/input ⌨️
    difficulty/medium 🤔
    project/keyboard ⌨️
    and removed
    triage/untriaged
    difficulty/tbd
    on Oct 25, 2023
  9. Youssef1313 commented on Oct 25, 2023

    @Youssef1313
    Member

    https://developer.android.com/reference/android/view/KeyEvent.html

    As soft input methods can use multiple and inventive ways of inputting text, there is no guarantee that any key press on a soft keyboard will generate a key event: this is left to the IME's discretion, and in fact sending such events is discouraged. You should never rely on receiving KeyEvents for any key on a soft input method. In particular, the default software keyboard will never send any key event to any application targetting Jelly Bean or later, and will only send events for some presses of the delete and return keys to applications targetting Ice Cream Sandwich or earlier. Be aware that other software input methods may never send key events regardless of the version. Consider using editor actions like EditorInfo.IME_ACTION_DONE if you need specific interaction with the software keyboard, as it gives more visibility to the user as to how your application will react to key presses

    https://developer.android.com/develop/ui/views/touch-and-input/keyboard-input/commands

    Note: When handling keyboard events with the KeyEvent class and related APIs, expect that the keyboard events are coming only from a hardware keyboard. Never rely on receiving key events for any key on a soft input method (an on-screen keyboard).

    There doesn't seem to be a way for us to reliably detect input from soft keyboard. This feels like a platform limitation that we can't do anything about.

  10. removed their assignment
    on Nov 7, 2023
  11. github-actions commented on Dec 27, 2025

    @github-actions
    Contributor

    Hey there — just a heads-up that this issue has been quiet for over a year. If there’s no update or comment in the next 10 days, it’ll be closed automatically. Feel free to remove the stale label or drop a note to keep it open.

  12. added
    stale
    on Dec 27, 2025
  13. removed
    stale
    on Dec 29, 2025
  14. added
    triage/potentially-fixed
    on Apr 20, 2026
  15. MartinZikmund commented on Apr 20, 2026

    @MartinZikmund
    Member

    Repro generator

    Runtime test(s) added in branch dev/mazi/repro/13983:

    • src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs → When_TextBox_Focused_And_Key_Pressed_Then_KeyDown_Fires
    • src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs → When_TextBox_Focused_And_Enter_Pressed_Then_KeyDown_Fires

    ⚠️ The test(s) pass on Skia targets. The issue reports the bug on Android (Google Pixel 6), which is a native target not covered by the Skia runtime test runner. This bug is likely native-target-specific and may not reproduce on Skia. A PR has been created to add the passing test(s) as regression coverage.

    Note: The tests use OnKeyTestingOnly which bypasses the virtual keyboard (IME) layer. The actual Android bug may be in the IME event routing path, which requires device-level testing to verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

difficulty/medium 🤔has-repro-branchkind/regressionproject/input ⌨️project/keyboard ⌨️triage/potentially-fixed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions