UIElement Keyboard Events

UIElement exposes two simple routed events for keyboard input: KeyDown and KeyUp. The EventArgs parameter passed to keyboard event handlers is a KeyRoutedEventArgs instance that contains the following properties:

Key—The key that was pressed or released. This property is of type Windows.System.VirtualKey, a large enumeration of every possible key.

KeyStatus—Reports extended information for certain keys.

Handled—The typical routed event property that can “halt” bubbling.

Although an app might be used with a software keyboard or hardware keyboard, the resulting input looks identical.

The KeyStatus property is a Windows.UI.Core.CorePhysicalKeyStatus structure. In case you didn’t get all the hints from its name, this ...

Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.