WinUI3 KeyRoutedEventArgs getting key value as Menu after clicking on alt key.

Smrithi Surendran 61 Reputation points
2022-12-21T13:49:18.36+00:00

WinUI3 KeyRoutedEventArgs getting key value as Menu after clicking on alt key.

I want to display the exact key value in a textbox, after clicking on the alt button in keyboard.

Please help here.

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
839 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,336 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Roy Li - MSFT 34,101 Reputation points Microsoft External Staff
    2022-12-22T02:15:16.56+00:00

    Hello,

    Welcome to Microsoft Q&A!

    WinUI3 KeyRoutedEventArgs getting key value as Menu after clicking on alt key.

    This is expected behavior. The key property of the KeyRoutedEventArgs is a Windows.System.VirtualKey Enum. As you could see in the VirtualKey Enum document, the LeftMenu corresponding to the left Alt key and the Menu corresponding to the Alt key.

    If you want to display Alt value in your TextBox, you might need to have a special check for the Alt key. Take keyDown event as example, you might need to check the key value before you display it, and if you found the pressed key is Menu, then manually display the value as Alt

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.