Skip to content

[Skia][WASM] Enter on a hardware keyboard raises KeyDown and KeyUp twice in a TextBox #25173

Open

Description

@mikernet

Current behavior 🐛

On Skia WebAssembly, Enter pressed on a hardware keyboard in a TextBox or PasswordBox that does not accept returns raises KeyDown twice and KeyUp twice. A trusted Enter press sent through the DevTools protocol (Chrome 154 on Windows) gives KeyDown, KeyDown, KeyUp, KeyUp, and so does the Enter of the numeric keypad.

The hidden input lets the keydown through to BrowserKeyboardInputSource, which raises KeyDown. Nothing prevents the event, so the browser sets out to insert a line break and fires beforeinput (insertLineBreak). The handler of that calls OnEnterKeyPressed, which raises KeyDown again and, since #24575, KeyUp. The keyup then goes through BrowserKeyboardInputSource and raises KeyUp a second time. Chrome's own events for the press are keydown, keypress, beforeinput, keyup.

The second KeyUp goes to whatever has focus by then. A KeyUp handler that moves focus to the next field therefore skips a field when the next one has the same handler, and a KeyDown handler that does not set Handled, such as one that submits a form, runs twice.

A keyup of Enter that has a code and comes without a keydown of Enter is raised as KeyDown, KeyUp, KeyUp the same way: OnEnterKeyPressed raises both, and the keyup still goes on to BrowserKeyboardInputSource. That one was seen by replaying the DOM events on the hidden input. An Enter that commits an IME composition has that shape, its keydown being reported as Process, but it was not tried with an IME.

Expected behavior 🎯

One KeyDown and one KeyUp per press, as on the other targets.

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

<StackPanel>
	<TextBox KeyDown="OnKeyDown" KeyUp="OnKeyUp" />
	<TextBlock x:Name="Log" />
</StackPanel>
private void OnKeyDown(object sender, KeyRoutedEventArgs e) => Log.Text += $"down:{e.Key} ";

private void OnKeyUp(object sender, KeyRoutedEventArgs e) => Log.Text += $"up:{e.Key} ";

Run the WebAssembly head in a desktop browser, focus the TextBox and press Enter. The log reads down:Enter down:Enter up:Enter up:Enter.

Workaround 🛠️

Going by the code, setting e.Handled = true in a KeyDown handler for Enter: BrowserKeyboardInputSource then prevents the keydown, so no beforeinput should follow it. Not tried.

Affected platforms 📱💻🖥️

WebAssembly (Skia renderer)

Uno.Sdk version (and other relevant versions) 📦

master at ab363dc. A 6.8 build, which predates #24575, has the first half: KeyDown twice, KeyUp once. release/stable/6.7 carries the same code as 6.8 here.

IDE version 🧑‍💻

Not IDE related.

Anything else we need to know? 💬

The beforeinput route came with #22299 for the Android soft keyboards, whose Enter has no code for BrowserKeyboardInputSource to tell the key by. A PR with a fix follows. It keeps that route for them and stops it from raising a key that already went through the keyboard input source.

Activity

  1. added
    7.1
    on Oct 14, 2026
  2. removed
    7.1
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions