-
Notifications
You must be signed in to change notification settings - Fork 912
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
WindowEvent missing virtual_keycode while DeviceEvent contains it on Linux #1443
Comments
Well, the reason this happens is pretty straightforward: On X11, winit chooses the winit/src/platform_impl/linux/x11/util/keys.rs Lines 65 to 69 in 28f0eb5
EDIT: Oops, didn't mean to submit this comment so soon. So, for device events,
Of course, the "why?" of this issue is not so clear, I think. What should the |
Dollar is not a valid VirtualKeyCode, is it? Just like all other keys, the VirtualKeyCode should be the same regardless of the modifier pressed. It will just have an additional Couldn't winit just use It seems that Wayland at least manages to properly return a VirtualKeyCode here. |
I'm not sure what Should winit instead always report |
It depends on the used layout afaik. |
I'm not sure what you mean, but what I'm trying to say is, I agree that this issue is legitimate, but I'm not sure how to resolve it, as winit exhibits some inconsistency with regard to modifiers and If we're to solve this issue, I think we need to definitively answer this question: Should
I don't know the answer to the above question. It depends on the needs of applications. Do you have a preference toward either of the above scenarios? |
I'm saying that special VirtualKeyCodes like colon usually appear on different layouts which do have these as base keys.
I think it would be nice to have both, however I don't think that's easily possible. So since this is not possible (we're not going to generate a VirtualKeyCode for Ö, right?), the only logical solution is to send it for the base key, not the "produced" value. As an anecdote, Alacritty has had a long standing issue that key combinations like Ctrl++ to increase the default font size do not work because of different keyboard layouts. However, there's a simple solution for this: Allowing people to map keybindings to |
I think it's a safe working assumption that there exists a keyboard layout out there somewhere with every permutation of shift/ctrl/etc modifiers with every possible character. Meaning while I have Can we inspect the keyboard layout for the keyboard device (do we do that already, sorry for my ignorance)? Otherwise, I feel like treating each key as a single name, with modifiers is the safest, and simplest option. |
This has been reproduced on Wayland too. |
Wayland works only because it uses a separate concept for this thing. it maps raw keys, and not keysyms, however I'm about to change that in #1534 , but it does that only for numbers, and not for the rest of the keys
I feel like we should add VIrtualKeyCodes for @murarth Also, I wonder what should we do about non latin layouts, since XKB has a special keysym for those things, so right now it's impossible to bind Russian I don't see any activity recently in winit, but I'm fine with maintaining Wayland backend, since I'm familiar with it the most and we need winit in alacritty, so I kind of have to. |
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 just noticed on X11 that some WindowEvents do not contain virtual keycodes, while their DeviceEvents do contain them.
The events look like this:
What is interesting to me is that Shift+4 does not contain a
virtual_keycode
, while 4 does.The text was updated successfully, but these errors were encountered: