When mouse clicking or typing a key in your Silverlight application how do you know if any combination of the <Alt>, <Shift>, <Ctrl>, <Windows> and/or <Apple> keys are down as well?
To accomplish this you simply need to check the Keyboard.Modifiers member which returns a ModifierKeys object.
The following code demonstrates how to get this object and how to check if any of these keys have been pressed:
ModifierKeys keys = Keyboard.Modifiers;
bool shiftKey = (keys & ModifierKeys.Shift) != 0;
bool altKey = (keys & ModifierKeys.Alt) != 0;
bool appleKey = (keys & ModifierKeys.Apple) != 0;
bool controlKey = (keys & ModifierKeys.Control) != 0;
bool windowsKey = (keys & ModifierKeys.Windows) != 0;
Source: Tip8_ModifierKeys
Demo:
[silverlight: Tip8_ModiferKeys.xap]
Thank you,
–Mike






