-
Notifications
You must be signed in to change notification settings - Fork 901
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
wasm: WindowEvent::CharacterReceived is not sent anymore #1741
Comments
Please, next time provide platform you're using more clearly, so it'll save us time guessing about what you're talking about. cc @ryanisaacg |
Apologies. What would be the best/preferred way to reduce the amount of guessing for you? (for future reports) |
Ah, you've put something like
Could help. |
That commit for PR #1576 was to fix #1573. That issue focused on page scrolling, but scrolling is not the only concern. Here are some examples of keys that associates with some browser default actions (excluding the unblockable ones):
It seems reasonable that Winit should block their default behaviour when the canvas is in focus (except for Tab/Shift+Tab (*) ). We may change Winit to only call (*) Tab/Shift+Tab is a bit tricky due to accessibility. Blocking them is fine for games, but some use cases might benefit from conditionally blocking/unblocking them. However, accessibility for canvas elements is pretty bad in general, so we can probably just ignore this for now. |
That makes sense. I see why it's necessary to call The MDN docs suggest that the I'd be happy to try to make a patch, if there's agreement on the approach. |
I think the approach of "see if this key can be typed, and if so do not prevent default" is a good one. |
I think matching against a list of keys that can produce a character input should be good. The list would probably be a combination of alphanumeric keys and some symbol keys. Note that it also needs to check the modifier keys so that it can also block some key combinations like Ctrl+L, without preventing Shift+L from producing uppercase "L". I am a bit worried about accented characters that are input by AltGr+alpha as I don't know how they work at all. It might be a good idea to write a small JavaScript POC to test for a bit on different platforms and browsers. IME composition is another beast which might have an effect, but since Winit doesn't yet support IME composition we don't need to deal with it now. |
Wouldn't it perhaps be easier to go the other way around and instead of checking whether the key can be typed, check whether the key can not be typed? It seems to me that this would be a shorter and more well-defined (specified) set. In particular I'm thinking of what's listed here https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values as well as "Dead" and "Undefined". I might very well be missing something though :) |
I took another look and I think checking whether the key can be typed would be easier. The simple way might be to just check whether We might also be able to cheat by just doing let event_key: &str = event.key();
let is_key_string = event_key.len() == 1 || !event_key.is_ascii(); This would be more generic than comparing against a predefined list. See https://www.w3.org/TR/uievents-key/#key-attr-values, and I quote:
|
The event was never sent to the application because of the unconditional preventDefault() call on keydown. Fixes rust-windowing#1741
I've implemented the logic suggested by @alvinhochun in the linked PR. |
The event was never sent to the application because of the unconditional preventDefault() call on keydown. Fixes rust-windowing#1741
The event was never sent to the application because of the unconditional preventDefault() call on keydown. Fixes rust-windowing#1741
The event was never sent to the application because of the unconditional preventDefault() call on keydown. Fixes rust-windowing#1741
The event was never sent to the application because of the unconditional preventDefault() call on keydown. Fixes rust-windowing#1741
After reaching keypress, we should prevent further propagation. Relates to rust-windowing#1741
Since 0.23 WindowEvent::CharacterReceived is not sent anymore. I tracked it down to commit 6cfddfe at
winit/src/platform_impl/web/web_sys/canvas.rs
Line 160 in 5a78fe3
prevent_default()
call results in thekeypress
event to be never received on the canvas element.This is happening at least with Safari and Chrome on macOS.
The text was updated successfully, but these errors were encountered: