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

KeyboardDragListener cares more about left arrow then right arrow #1549

Closed
zepumph opened this issue Mar 22, 2023 · 3 comments
Closed

KeyboardDragListener cares more about left arrow then right arrow #1549

zepumph opened this issue Mar 22, 2023 · 3 comments

Comments

@zepumph
Copy link
Member

zepumph commented Mar 22, 2023

Discovered while reviewing phetsims/my-solar-system#86.

Because of the implementation of dragging, left will take precedent if both are down. Instead of this block, should we care about which has been down for the least amount of time? That is probably the most idiomatic.

if ( this.leftMovementKeysDown() ) {
deltaX = -delta;
}
else if ( this.rightMovementKeysDown() ) {
deltaX = delta;
}
if ( this.upMovementKeysDown() ) {
deltaY = -delta;
}
else if ( this.downMovementKeysDown() ) {
deltaY = delta;
}

@jessegreenberg have we discussed this before? I can't tell if it is a bug.

@zepumph
Copy link
Member Author

zepumph commented Mar 22, 2023

There are two possible ways we could have fixed this inconsistency.

  1. Both directions down cancel each other out
  2. If both down, take the value from the "most recent" direction down.

(1) is much much easier to implement, so that is where we will start. We also like it quite a bit. @jessegreenberg can you recommend if you'd prefer to see (2)? Please review.

@zepumph
Copy link
Member Author

zepumph commented Mar 22, 2023

Tested in MSS, BASE, and Friction

@jessegreenberg
Copy link
Contributor

Thanks! I have flip-flopped on this, I changed it last in #1460. I like your change. 1) also seems most expected for 2D dragging and gaming contexts. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants