-
Notifications
You must be signed in to change notification settings - Fork 940
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
Wrong key codes for Shift+Number and others - German/Other^^^ keyboard layouts for macOS not supported? #2631
Comments
I think this is the desired behaviour when IME is disabled? See |
Of course. But IME (Text input) is not my topic. In winit, the key detection is done by: "Non-Shift-Char OR Shift-Char" Adding code for different keyboard layouts would be an attempt and at last useless For internationalisation, scancode_to_keycode needs to be used. wini could offer constants for scan-codes to. Not "row4_key12" but "VirtualKeyCode::Escape". I could offer a merge to wini, adding "scancode_to_keypos" (position) with that table. |
I haven't really fiddled much with keyboard layouts, so I think I'll direct you to #1806, there has been much work in the past on improving the situation. |
Thanks! A lot to read ...
That #753 discussion looks good. I assume, it will solve my problems. |
This is something I think you won't have an issue with once the keyboard rework lands (see https://github.com/rust-windowing/winit/tree/new-keyboard-v3 for the most up-to-date state of that). |
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 <[email protected]> Co-Authored-By: Kirill Chibisov <[email protected]> Co-Authored-By: daxpedda <[email protected]> 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.
I am using a Mac Air with a German keyboard layout.
Bevy includes winit "0.27.5"
While the number keys 1..9 and 0 are ok,
pressing one of the shift keys puzzles me:
Shift+1 comes as "Key1", not "!"
Shift+2 comes correctly as "Apostrophe"
Shift+3 comes as "Key3", not "§"
Shift+4 comes as "Key4", not "$"
Shift+5 comes as "Key5", not "%"
Shift+6 comes as "Key7" Seven! not "&"
Shift+7 comes correctly as "Slash"
Shift+8 comes as "Key9" ! not "("
Shift+9 comes as "Key0" ! not ")"
Shift+0 comes correctly as "Equal"
Some keys result in odd key-codes also:
The + key comes as "Equals"
The # key comes as "Key3" to
In winit/src/platform_impl/macos/event.rs I see how that could be caused.
'3' | '#' => VirtualKeyCode::Key3,
WINIT does not consider different keyboard layouts (for mac) anyway.
Mostly I can consider this in my code, but not for all, the 3/# for example.
I checked for the scan codes, they look ok. Using them would be a workaround
but I need to consider different keyboard layouts myself!
The text was updated successfully, but these errors were encountered: