From db777c7bde2ad075f2a76cf6d5e9c20b04d62a2d Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 21 Feb 2020 11:11:59 +0100 Subject: Fix event.key for Ctrl key combinations on Windows Fixes: QTBUG-81783 Change-Id: I107a4009630dc261013498a05987c0e8e29651eb Reviewed-by: Allan Sandfeld Jensen --- src/core/web_event_factory.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/core/web_event_factory.cpp') diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index ba04806d5..f4940f305 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -157,8 +157,11 @@ static Qt::KeyboardModifiers qtModifiersForEvent(const QInputEvent *ev) // // On Linux, the Control modifier transformation is applied [1]. For example, // pressing Ctrl+@ generates the text "\u0000". We would like "@" instead. +// Windows also translates some control key combinations into ASCII control +// characters [2]. // // [1]: https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Interpreting_the_Control_Modifier +// [2]: https://docs.microsoft.com/en-us/windows/win32/learnwin32/keyboard-input#character-messages // // On macOS, if the Control modifier is used, then no text is generated at all. // We need some text. @@ -171,8 +174,10 @@ static QString qtTextForKeyEvent(const QKeyEvent *ev, int qtKey, Qt::KeyboardMod { QString text = ev->text(); - if ((qtModifiers & Qt::ControlModifier) && keyboardDriver() == KeyboardDriver::Xkb) + if ((qtModifiers & Qt::ControlModifier) && + (keyboardDriver() == KeyboardDriver::Xkb || keyboardDriver() == KeyboardDriver::Windows)) { text.clear(); + } return text; } -- cgit v1.2.3