-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
keys held down are no longer listened to when another key is pressed #502
Comments
oops 😭 |
So, it looks like we confused ourselves. The function we actually wanted above was I posit, this is mega confusing 😞 How about this instead:
|
This also has implications for the event based api as well
|
Yah that makes more sense I think... On Tue, Aug 18, 2015 at 10:09 PM Erik Onarheim notifications@github.com
|
Might be easier to walk through an event sequence: User presses and releases "H" key
User holds key "H" down and then releases
Given this, the original API does make technical sense (only one keydown vs. many keypresses) but it's easy to be confused, since I had to write this out to explain it. If we wanted to make it clearer we would need different terminology than the usual JS "keypress" and "keydown" terms because colloquially down and pressed mean the same thing. We could do something like:
So in example 1:
And example 2:
|
WentUp/wentDown/isHeld? Similarly on (up/down/hold)? I feel like went is more appropriate than is here because it captures the state transition (you could argue or expect that every key on a keyboard that is not in use is up), and that down/hold is a clearer destinction than down/pressed or down/justdown. |
I would say something like becameUp but that seems way too long |
If we change this you could also still alias the typical js event names for this for people that are used to that |
After thinking about it a little more, i think i like wasPressed/wasReleased/isHeld, and on press/release/hold |
@alanag13 I like those too I think. |
@alanag13 @kamranayub I like the was- prefix on this because it feels like something happened.What do you guys think of Is Also, does this mean we want to rename our event based api to reflect this? or create aliases to the existing api? or is the existing event based api clear?
|
the names of the state checks and event apis should optimally align, imo. This would make it more clear which event causes which state. Therefore we would have and
Terminology should be consistent. For events it should be the name of the action being performed (i.e. I don't have strong opinions about the aliasing of the old api. I think this is much clearer from a simple choice of words standpoint (and think for this reason we should make these the "main" methods either way), but I can also see how a seasoned js developer might try these events based on the more commonplace keydown, keypress, and keyup events. |
I think the addition of I think its probably safe to assume that no one using the api would think |
I definitely agree the pressed/released/held is a more clear way of dealing with this. The only sticker is the seasoned js programmer trying the up/down/pressed because of familiarity, but I'm willing to sacrifice that experience if we feel aliasing pressed/down, released/up, pressed/held in the event api is too bad. Yah, the |
Have to remember we aren't necessarily targeting seasoned JS developers--furthermore, those event names make sense for browser key handling but in a game they don't as much--e.g. Also I feel it's okay to deviate from "common" JS events if it makes sense in our context or if it's plain confusing--which it was. |
If it helps here are unity's methods:
I don't mind that API personally. |
Doesnt that reinstate the problem of it being difficult to distinguish between down and press? Its super easy to think getbuttondown would be true when held down here, especially since the method that does do that is just called getbutton. I would never expect getNoun to return a boolean.... |
And again, i might expect getkeyup to be true for all keys by default. I think wasReleased makes it clear that it is only true for that small moment in time. |
Please review the changes, i actually like doing things this way. |
Fixed with #524 |
Given an custom
actor.update()
:example: If you hold down 'up', and then tap 'down', while still holding 'up', the 'up' key is ignored (and vice versa).
The text was updated successfully, but these errors were encountered: