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

Add keyboard service #647

Merged
merged 6 commits into from
Sep 27, 2019
Merged

Add keyboard service #647

merged 6 commits into from
Sep 27, 2019

Conversation

hgzimmerman
Copy link
Member

@hgzimmerman hgzimmerman commented Sep 17, 2019

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?

@jstarry
Copy link
Member

jstarry commented Sep 22, 2019

I agree that services should be feature gated, thanks for creating the issue #648 for it!

@jstarry jstarry self-requested a review September 22, 2019 19:42
Copy link
Member

@jstarry jstarry left a 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!

@hgzimmerman
Copy link
Member Author

Would it be wise to expand the scope of this PR to include all GlobalEventHandlers as a service instead of just keyboard-specific events?

@jstarry jstarry merged commit 0ae9cd5 into yewstack:master Sep 27, 2019
llebout pushed a commit to llebout/yew that referenced this pull request Jan 20, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants