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

Duplicate KeyUp events are raised for arrow keys #9399

Closed
jeremy-visionaid opened this issue Mar 5, 2024 · 5 comments
Closed

Duplicate KeyUp events are raised for arrow keys #9399

jeremy-visionaid opened this issue Mar 5, 2024 · 5 comments
Labels
area-KeyboardAccelerators bug Something isn't working closed-Fixed Described behavior has been fixed. fix-released The fix has been in a release (experimental, preview, stable, or servicing). team-Controls Issue for the Controls team
Milestone

Comments

@jeremy-visionaid
Copy link

Describe the bug

When an arrow key is pressed and released, the KeyUp event is raised twice

Steps to reproduce the bug

        public MainWindow()
        {
            this.InitializeComponent();

            grid.KeyDown += Grid_KeyDown;

            grid.KeyUp += Grid_KeyUp;
        }

        private void Grid_KeyDown(object sender, KeyRoutedEventArgs e)
        {
            Debug.WriteLine($"KeyDown: {e.Key}");
        }

        private void Grid_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            Debug.WriteLine($"KeyUp: {e.Key}");
        }

Press and release the "Up" arrow key. It then prints:

KeyDown: Up
KeyUp: Up
KeyUp: Up

Expected behavior

The KeyUp event should only be raised once. i.e.

KeyDown: Up
KeyUp: Up

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.5.0: 1.5.240227000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@jeremy-visionaid jeremy-visionaid added the bug Something isn't working label Mar 5, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Mar 5, 2024
@jeremy-visionaid
Copy link
Author

Repro available here:
https://github.com/molesmoke/WinUITestApp/tree/keyup

@codendone codendone added area-KeyboardAccelerators team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Apr 5, 2024
@codendone
Copy link
Contributor

It looks like CXamlIslandRoot::PreTranslateMessage() results in delivering an CXamlIslandRoot::OnIslandKeyUp(), which gets handled as a normal key up, and then the standard key input still gets delivered to CXamlIslandRoot::OnIslandKeyUp(), causing it to be processed again. Something needs to change so only one or the other gets delivered/processed.

@jeremy-visionaid
Copy link
Author

jeremy-visionaid commented Apr 10, 2024

@codendone Maybe related if you're looking into this one, key down events are not raised for some combinations: #9253

@jeremy-visionaid
Copy link
Author

Still present in v1.5.240607001

@llongley llongley added this to the WinAppSDK 1.6 milestone Jun 28, 2024
@llongley llongley added the closed-Fixed Described behavior has been fixed. label Jun 28, 2024
@codendone codendone added the fix-released The fix has been in a release (experimental, preview, stable, or servicing). label Jul 3, 2024
@codendone
Copy link
Contributor

This is fixed in 1.6.240701003-experimental2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-KeyboardAccelerators bug Something isn't working closed-Fixed Described behavior has been fixed. fix-released The fix has been in a release (experimental, preview, stable, or servicing). team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

3 participants