-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add keyboard service #647
Add keyboard service #647
Conversation
I agree that services should be feature gated, thanks for creating the issue #648 for it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but I think we should add some comments about compatibility. Looks like these events are not supported on some browsers like Safari for example. Please add a note about that and a link to https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers, thanks!
Would it be wise to expand the scope of this PR to include all GlobalEventHandlers as a service instead of just keyboard-specific events? |
* Add keyboard service * fix not working implementation; run cargo fmt * make callback to keyboard event use KeyPressEvent instead of String * add key_down and key_up events as well * link to documentation and provide compatibility notice
Adds a keyboard service so key events can be registered on elements like
document
.Thanks to cradee (@cradee_gitlab on the yew gitter) for making it apparent something like this might be useful and for implementing a prototype.
Edit: a thought related to this feature.
This service is pretty simple, and could be done in someone's own project without too much difficulty. Should there be a bar that must be cleared for service additions? Would it make sense to create another project within yewstack for accessory services - ones that aren't core to most applications, but are common enough to justify sticking them in a library for reuse? Should all services be moved to another crate and be reexported from yew but gated by a default "on" feature flag?