-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot extract original character when receiving a Ctrl character. #1700
Comments
This sounds like you want to look at the |
I don't see how |
On Windows, you can use Implementing something like this directly in winit itself has been briefly mentioned, but that seems to have been intended for "display purposes". Honestly, if you're expecting winit to have some sort of good solution for keyboard shortcuts then you're SOL, because all the options have some major downsides.
I don't really expect this situation to change much unless we can get some momentum behind a solution for #753. |
Thank you for the in-depth description! I'm wondering how do other applications handle keyboard shortcuts with let's say Russian or Arabic keyboard layouts. When listing the available keyboard shortcuts, what do applications show on the GUI to the user with such layouts? Do they display the "virtual key" or do they display the layout dependent character? If it's the virtual key than this really is not an issue - or more like an issue that already has a widely accepted workaround. |
I do expect the keyboard handling situation to get better, but that won't fix this problem. The biggest problem right now is just with consistency, one platform does it one way and another platform does it differently. Even on the same platform you run into issues where suddenly DeviceEvent has a VirtualKeyCode but WindowEvent doesn't. Generally what winit does right now with offering all of scancode/received_char/VirtualKeyCode is relatively similar to what the browser does and it's a decent solution.
Not a lot of applications have keyboard shortcuts and even fewer of those have the necessity that users type in the names of those shortcuts manually. If you set them by having the user press the button, it's becomes relatively trivial. |
Portable shortcuts are not a trivial problem, and not just for Rust / winit. Qt has some notes on this, in particular:
Thus, Qt provides a library of platform-specific common shortcuts. Of course this doesn't solve everything. |
Yep. I've been trying to untangle "Alt Graph" on the Windows backend, as well as trying to figure out how to deal with "Pause/Break" and "NumLock" being weird. I'll submit a PR when the code is in a state I'm somewhat comfortable with. |
Will #1932 fix this issue for Linux? Are there any plans to fix this on other platforms as well? Are there any workaround to the issue of not getting the characters in |
Yes
#1932 is part of an effort to overhaul the cross-platform keyboard input API (see #1806).
Maybe, but I can't think of a convenient one. |
Overhaul the keyboard API in winit to mimic the W3C specification to achieve better crossplatform parity. The `KeyboardInput` event is now uses `KeyEvent` which consists of: - `physical_key` - a cross platform way to refer to scancodes; - `logical_key` - keysym value, which shows your key respecting the layout; - `text` - the text produced by this keypress; - `location` - the location of the key on the keyboard; - `repeat` - whether the key was produced by the repeat. And also a `platform_specific` field which encapsulates extra information on desktop platforms, like key without modifiers and text with all modifiers. The `Modifiers` were also slightly reworked as in, the information whether the left or right modifier is pressed is now also exposed on platforms where it could be queried reliably. The support was also added for the web and orbital platforms finishing the API change. This change made the `OptionAsAlt` API on macOS redundant thus it was removed all together. Co-Authored-By: Artúr Kovács <kovacs.artur.barnabas@gmail.com> Co-Authored-By: Kirill Chibisov <contact@kchibisov.com> Co-Authored-By: daxpedda <daxpedda@gmail.com> Fixes: #2631. Fixes: #2055. Fixes: #2032. Fixes: #1904. Fixes: #1810. Fixes: #1700. Fixes: #1443. Fixes: #1343. Fixes: #1208. Fixes: #1151. Fixes: #812. Fixes: #600. Fixes: #361. Fixes: #343.
When I use a keyboard layout with keys that are not from basic latin, and I press a non-basic-latin letter in conjunction with Ctrl the following happens:
VirtualKeyCode
seems to be the character at the same location from the US layout.ReceivedCharacter
is sometimes identical to theVirtualKeyCode
but it's sometimes an ASCII control character.This happens on both Linux with X11 and on Windows. Actually, on Windows the
ReceivedCharacter
isn't even sent for some combinations.The issue is that it seems the application has no way of telling what was the original key pressed. So for example if I'm using a Hungarian layout and I press Ctrl+ű I get a
'\u{1c}'
inReceivedCharacter
and my applications has no idea that ű was ever pressed. This may not be relevant for text input but it's relevant for shortcuts.The text was updated successfully, but these errors were encountered: