-
Notifications
You must be signed in to change notification settings - Fork 154
KeyboardEvent.key
parsing
#91
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
Comments
I think this should be exposed as part of #43
I don't think it should be shortened as far as
I think it's reasonable to provide a |
The |
It seems that that crate could be used. Do you have an exposed gloo API in mind? |
This crate, at least for So I'd say it probably makes sense to use the crate, but there needs to be a PR to make it usable with real world browsers. |
Summary
Add a crate to parse the
KeyboardEvent.key
field.Motivation
If you're writing a game or similar, you may want to handle raw keyboard events. The
key
event is a string, meaning that the names of the special keys are not discoverable. By parsing it into an enum, we make them discoverable, while also making the key cheaper to copy, except for theUnknown
degenerate case.It seems like a good candidate for inclusion in
gloo
since it doesn't make any design decisions (it's just parsing the ECMAScript spec), but it's quite a lot of work to implement.Detailed Explanation
The enum would look like (modulo bikeshedding)
and would be parsed like
Drawbacks, Rationale, and Alternatives
Possible drawbacks
It could possibly be slower than working directly with strings, although it would be cheaper to clone/etc unless you are in the degenerate "Unknown" case.
Maybe no-one will use it
The alternative is to not do this.
Unresolved Questions
K
, to be more concise?char
methods should we implement?Backspace
) to their char code (e.g.char::from_u32(8)
)The text was updated successfully, but these errors were encountered: