-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Add support for ButtonInput<Key> #19684
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
Conversation
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
My initial stance on this as SME-Input is that a) we should do this and b) we need to be extremely careful about docs here. |
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.
Makes sense to me.
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.
I think this PR generally makes sense, but I think to avoid any footguns the docs of KeyCode should point to Key
and explain why they might want it and the reverse should also be done. I also think Key::Character should point to KeyCode to let users know they might want to use that one instead.
Maybe we should rename Key to LogicalKey? That I don't know, but treating Key and KeyCode on the same level makes sense to me.
Yeah definitely the docs need to be improved, I'll do that soon and take the PR out of draft when I'm done.
|
@alice-i-cecile I added docs and release notes, let me know if you want more docs in other areas as well. |
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.
I'm happy with the level of clarity here, and I think we should expose this.
Objective
While
KeyCode
is very often the correct way to interact with keyboard input there are a bunch of cases where it isn't, notably most of the symbols (e.g. plus, minus, different parentheses). Currently the only way to get these is to read fromEventReader<KeyboardInput>
, but then you'd have to redo theButtonInput
logic for pressed/released to e.g. make zoom functionality that depends on plus/minus keys.This has led to confusion previously, like #3278
Solution
Add a
ButtonInput<Key>
resource.Testing
Modified the
keyboard_input
example to test it.Open questions
I'm not 100% sure this is the right way forward, since it duplicates the key processing logic and might make people use the shorter
ButtonInput<Key>
even when it's not appropriate.Another option is to add a new struct with both
Key
andKeyCode
, and useButtonInput
with that instead. That would make it more explanatory, but that is a lot of churn.The third alternative is to not do this because it's too niche.
I'll add more documentation and take it out of draft if we want to move forward with it.