Keyboard Modifiers in Pointer Events

Although the keyboard events are not pointer events, the pointer events do report some information about the current state of the keyboard via the PointerRoutedEventArgs.KeyModifiers property. The idea is that certain special keys are pressed to “modify” another gesture.

The property is of type Windows.System.VirtualKeyModifiers, another enumeration. It reveals whether certain keys are currently pressed: Control, Shift, Windows, Menu (the Alt key), or None. Naturally, this is a flags enumeration because any number of these can be pressed simultaneously. Therefore, you don’t want to check for equality unless you care about the state of every modifier key. For example, the following code checks whether Alt is ...

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.