In my C# application I want to display a context menu, but I want to add special options to the menu if the SHIFT key is being held down when the context menu is opened.
Keyboard.Modifiers
also works with actual WPF projects!
Also I would recommend it's use over Keyboard.GetKeyStates
because the latter uses triggering and may not reflect the real key state.
Also be aware that this will trigger ONLY if the shift modifier key is down and nothing else:
if(Keyboard.Modifiers == ModifierKeys.Shift)
{ ... }
If you just want to detect if the shift key is down, whether another modifier key is pressed or not, use this one:
if((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
{ ... }