private void TextBox_KeyDown()

in src/AccessibilityInsights.SharedUx/Dialogs/HotkeyGrabDialog.xaml.cs [37:74]


        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            Key tempKey = (e.Key == Key.System ? e.SystemKey : e.Key);

            switch (tempKey)
            {
                case Key.Escape:
                case Key.Tab:
                    return;
                case Key.LeftAlt:
                case Key.RightAlt:
                    ModKey |= ModifierKeys.Alt;
                    break;
                case Key.LeftCtrl:
                case Key.RightCtrl:
                    ModKey |= ModifierKeys.Control;
                    break;
                case Key.LeftShift:
                case Key.RightShift:
                    ModKey |= ModifierKeys.Shift;
                    break;
                case Key.LWin:
                case Key.RWin:
                    ModKey |= ModifierKeys.Windows;
                    break;
                default:
                    SelectedKey = tempKey;
                    break;
            }

            UpdateHotkeyText();

            if (ModKey != ModifierKeys.None && SelectedKey != Key.None)
            {
                ButtonParent.Content = string.Format(CultureInfo.InvariantCulture, "{0} + {1}", GetCleanModifierString(), GetCleanKeyString());
                this.Close();
            }
        }