Not a duplicate of this question.
I’m trying to check if the “alt” key is held down while listening to an element’s KeyDown event like so:
private void AutoSuggestBox_OnKeyDown(object sender, KeyRoutedEventArgs e)
{
if (/* alt is pressed and */ e.Key == VirtualKey.Down)
{
(sender as AutoSuggestBox).IsSuggestionListOpen = true;
}
}
Per the linked question above, I know you can use InputKeyboardSourc.GetKeyStateForCurrentThread(key).HasFlag(CoreVirtualKeyStates.Down)
, but the key problem is: VirtualKey doesn’t seem to have a definition for the alt key (nor does VirutalKeyModifiers
).
I am aware that this likely means that one should avoid using the alt key in such a way, however I don’t have any choice in the requirement.