diff --git a/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml b/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml
index e828758..406c353 100644
--- a/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml
+++ b/demo/Ursa.Demo/Pages/KeyGestureInputDemo.axaml
@@ -13,8 +13,8 @@
mc:Ignorable="d">
-
+
-
+
-
+
\ No newline at end of file
diff --git a/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml b/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml
index 56aab72..2bbbd31 100644
--- a/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml
+++ b/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml
@@ -3,22 +3,25 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Avalonia.Controls.Converters"
xmlns:u="https://irihi.tech/ursa">
-
+
+
+
+
80
32
3
+ 1
diff --git a/src/Ursa/Controls/KeyGestureInput.cs b/src/Ursa/Controls/KeyGestureInput.cs
index 38dd28c..5c4e535 100644
--- a/src/Ursa/Controls/KeyGestureInput.cs
+++ b/src/Ursa/Controls/KeyGestureInput.cs
@@ -72,32 +72,24 @@ public class KeyGestureInput: TemplatedControl
if (!ConsiderKeyModifiers)
{
- if(e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl || e.Key == Key.LeftAlt || e.Key == Key.RightAlt || e.Key == Key.LeftShift || e.Key == Key.RightShift || e.Key == Key.LWin || e.Key == Key.RWin)
+ if(e.Key is Key.LeftCtrl or Key.RightCtrl or Key.LeftAlt or Key.RightAlt or Key.LeftShift or Key.RightShift or Key.LWin or Key.RWin)
{
return;
}
Gesture = new KeyGesture(e.Key);
}
KeyGesture gesture;
- if (e.KeyModifiers == KeyModifiers.Control && (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl))
+ switch (e.KeyModifiers)
{
- gesture = new KeyGesture(e.Key);
- }
- else if (e.KeyModifiers == KeyModifiers.Alt && (e.Key == Key.LeftAlt || e.Key == Key.RightAlt))
- {
- gesture = new KeyGesture(e.Key);
- }
- else if (e.KeyModifiers == KeyModifiers.Shift && (e.Key == Key.LeftShift || e.Key == Key.RightShift))
- {
- gesture = new KeyGesture(e.Key);
- }
- else if (e.KeyModifiers == KeyModifiers.Meta && (e.Key == Key.LWin || e.Key == Key.RWin))
- {
- gesture = new KeyGesture(e.Key);
- }
- else
- {
- gesture = new KeyGesture(e.Key, e.KeyModifiers);
+ case KeyModifiers.Control when e.Key is Key.LeftCtrl or Key.RightCtrl:
+ case KeyModifiers.Alt when e.Key is Key.LeftAlt or Key.RightAlt:
+ case KeyModifiers.Shift when e.Key is Key.LeftShift or Key.RightShift:
+ case KeyModifiers.Meta when e.Key is Key.LWin or Key.RWin:
+ gesture = new KeyGesture(e.Key);
+ break;
+ default:
+ gesture = new KeyGesture(e.Key, e.KeyModifiers);
+ break;
}
Gesture = gesture;
e.Handled = true;