Skip to content

The Down Arrow key does not trigger the KeyDown event when the cursor is at position 0 in the TextBox #10522

@Tamilarasan-Paranthaman

Description

Describe the bug

The KeyDown event is not triggered for the Down Arrow key when the cursor is at position 0 in the TextBox. Only the KeyUp event is fired correctly when pressing the Down Arrow key.

This issue occurs only when the TextBox contains text. If the TextBox is empty, the KeyDown event is triggered as expected.

 <TextBox Height="50"
          Width="200"
          Text="Hello, World!"
          KeyDown="TextBox_KeyDown"
          KeyUp="TextBox_KeyUp">
  </TextBox>
  private void TextBox_KeyDown(object sender, KeyRoutedEventArgs e)
  {
     Debug.WriteLine("The TextBox Key Down fired  : " + e.Key.ToString());
  }

  private void TextBox_KeyUp(object sender, KeyRoutedEventArgs e)
  {
     Debug.WriteLine("The TextBox Key Up fired  : " + e.Key.ToString());
  }

Steps to reproduce the bug

  1. Run the attached sample.
  2. Tap the TextBox (ensure the cursor is at the 0th position).
  3. Press the Down Arrow key on the keyboard.
  4. Observe the Output window, the KeyDown event is not triggered, only the KeyUp event is triggered

Sample App

Expected behavior

The KeyDown event should be triggered properly when pressing the Down Arrow key.

Screenshots

TextBox.mp4

NuGet package version

WinUI 3 - Windows App SDK 1.7.1: 1.7.250401001

Windows version

Windows 11 (23H2): Build 22631

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingteam-ControlsIssue for the Controls team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions