[UWP] How to Clear Keyboard buffer data? RRS feed

  • Question

  • Hi,

    In my app, i have added characterReceived event to CoreWindow during app launch as follows:

     protected override async void OnLaunched(LaunchActivatedEventArgs e)
            Frame rootFrame = Window.Current.Content as Frame;

                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new Frame();
                    // Set the default language
                    rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                    rootFrame.NavigationFailed += OnNavigationFailed;

                    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                        //TODO: Load state from previously suspended application

                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;

                Window.Current.CoreWindow.CharacterReceived += KeyPress;

                if (rootFrame.Content == null)
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                // Ensure the current window is active


     void KeyPress(CoreWindow sender, CharacterReceivedEventArgs args)

        args.Handled = true;
        Debug.WriteLine("KeyPress " + Convert.ToChar(args.KeyCode));


    I want to clear the Keyboard buffer data.. how can i do that? 

    and... At some times the CharacterReceived event is not triggered when i enter some keys from my keyboard. What could be the reason for that? Can anyone suggest me a solution?


    Sunday, June 7, 2015 8:05 AM


  • AFAIK, there's no hook into the keyboard buffer.  If you were writing an LOB app, you could write a brokered component that would dig into the OS and perform this for you.  What's your end goal?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, June 8, 2015 2:50 PM