Skip to content
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

Ability to read keys from the whole window on WASM #10232

Open
SIGSTACKFAULT opened this issue Oct 23, 2023 · 2 comments
Open

Ability to read keys from the whole window on WASM #10232

SIGSTACKFAULT opened this issue Oct 23, 2023 · 2 comments
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Usability A simple quality-of-life change that makes Bevy easier to use O-Web Specific to web (WASM) builds S-Needs-Investigation This issue requires detective work to figure out what's going wrong

Comments

@SIGSTACKFAULT
Copy link
Contributor

SIGSTACKFAULT commented Oct 23, 2023

I'm unsure if this is a missing feature in bevy, winit, or some other dependency. Presumably someone here will at least know which other dependency I should yell at.

What problem does this solve or what need does it fill?

My "game" takes up only half the screen and i expect users to spend a lot of time clicking between the canvas and the rest of the webpage. I'd like keybinds to work when the game canvas isn't focused. so you can just hold Q instead of having to click in the canvas area then hold Q

What solution would you like?

An enum resource you can insert:

app.insert_resource(WebKeyboardMode::Global);

if this is a missing feature in one of bevy's dependencies then we'll have to wait for the dependency to add it, then WebKeyboardMode (placeholder name) would control it.

@SIGSTACKFAULT SIGSTACKFAULT added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels Oct 23, 2023
@alice-i-cecile alice-i-cecile added A-Input Player input via keyboard, mouse, gamepad, and more O-Web Specific to web (WASM) builds C-Usability A simple quality-of-life change that makes Bevy easier to use S-Needs-Investigation This issue requires detective work to figure out what's going wrong and removed C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels Oct 23, 2023
@daxpedda
Copy link
Contributor

This is probably an issue with Winit, but as the Web backend maintainer of Winit I can confidently say this is not in scope for Winit.

Even when Winit adds Views (rust-windowing/winit#696), any window will still be connected to a canvas, changing that would require significant design work and a really good justification.

Since rust-windowing/winit#3062, nothing prevents users from registering their own callbacks, which is what Bevy should do in this case if this is a desirable feature.

@mockersf
Copy link
Member

if your game is shared between the canvas owned by Bevy and html elements, you probably already have setup some communications between JS and Bevy, you would just need to add an event listener that forward the keyboards event to Bevy.

You can take a look at https://github.com/bevyengine/bevy/blob/main/crates/bevy_winit/src/web_resize.rs, it should have pretty much every thing you need, but for the window resize events.

I feel like this is a little too specific to be included in Bevy, but it shouldn't be an issue to add in your game, or publish an external plugin with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Usability A simple quality-of-life change that makes Bevy easier to use O-Web Specific to web (WASM) builds S-Needs-Investigation This issue requires detective work to figure out what's going wrong
Projects
None yet
Development

No branches or pull requests

4 participants