From e04ef76053ffdee2182223b393d1d0c69ec1a26d Mon Sep 17 00:00:00 2001 From: calisto-le <46937480+calisto-le@users.noreply.github.com> Date: Fri, 15 May 2026 16:56:20 +0200 Subject: [PATCH 1/2] Fix TextServicesManager scan code forwarding for TSF Fixes #11635 --- .../System/Windows/Input/TextServicesManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextServicesManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextServicesManager.cs index bed4fa4aa7a..f01a85a3e91 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextServicesManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextServicesManager.cs @@ -231,7 +231,7 @@ private bool TextServicesKeystroke(TextServicesContext context, KeyEventArgs key break; default: wParam = KeyInterop.VirtualKeyFromKey(keyArgs.RealKey); - scancode = 0; + scancode = keyArgs.ScanCode; break; } From bbb1513bd7d7f4a721f1bf617464ca0d50991027 Mon Sep 17 00:00:00 2001 From: calisto-le <46937480+calisto-le@users.noreply.github.com> Date: Sat, 16 May 2026 12:39:39 +0200 Subject: [PATCH 2/2] Preserve extended key flag in lParam --- .../System/Windows/Input/TextServicesManager.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextServicesManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextServicesManager.cs index f01a85a3e91..f4b09ed84e9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextServicesManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/TextServicesManager.cs @@ -235,7 +235,12 @@ private bool TextServicesKeystroke(TextServicesContext context, KeyEventArgs key break; } - lParam = (int)(((uint)scancode << 16) | 1); + lParam = (int)((((uint)scancode & 0xFF) << 16) | 1); + + if (keyArgs.IsExtendedKey) + { + lParam |= 1 << 24; + } if (keyArgs.RoutedEvent == Keyboard.PreviewKeyDownEvent/*keyArgs.IsDown*/) {