diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs index fdab76d0933d..72301e41d848 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs @@ -396,14 +396,16 @@ public async Task When_Ctrl_Backspace() SUT.Select(SUT.Text.Length, 0); await WindowHelper.WaitForIdle(); - SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.Back, VirtualKeyModifiers.Control)); + // on macOS it's option (menu/alt) and backspace to delete a word + var mod = OperatingSystem.IsMacOS() ? VirtualKeyModifiers.Menu : VirtualKeyModifiers.Control; + SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.Back, mod)); await WindowHelper.WaitForIdle(); Assert.AreEqual("lorem ipsum ", SUT.Text); Assert.AreEqual(SUT.Text.Length, SUT.SelectionStart); Assert.AreEqual(0, SUT.SelectionLength); - SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.Back, VirtualKeyModifiers.Control)); + SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.Back, mod)); await WindowHelper.WaitForIdle(); Assert.AreEqual("lorem ", SUT.Text); diff --git a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs index 2a0aec65e9d9..d82ae614c8a4 100644 --- a/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs +++ b/src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs @@ -538,6 +538,12 @@ args.Key is not (VirtualKey.Up or VirtualKey.Down or VirtualKey.Left or VirtualK private void KeyDownBack(KeyRoutedEventArgs args, ref string text, bool ctrl, bool shift, ref int selectionStart, ref int selectionLength) { + // on macOS it is `option` + `delete` (same location as backspace on PC keyboards) that removes the previous word + if (OperatingSystem.IsMacOS()) + { + ctrl = args.KeyboardModifiers.HasFlag(VirtualKeyModifiers.Menu); + } + if (HasPointerCapture) { return;