phetsims / sun

User-interface components for PhET simulations, built on top of Scenery.
MIT License
4 stars 12 forks source link

Slider input isn't working correctly from number pads #819

Closed jessegreenberg closed 1 year ago

jessegreenberg commented 1 year ago

Specifically, page up/page down/home/end are acting like normal arrow keys. This is not an issue for typical range sliders on the web, so it is a problem with AccessibleValueHandler and the way it responds to key presses.

From https://github.com/phetsims/ratio-and-proportion/issues/542.

zepumph commented 1 year ago

Is this because of different key codes? Can we just add support for that key code too?

jessegreenberg commented 1 year ago

Testing a vanilla HTML slider, when num on, the number pad does nothing. When num lock is of, the number pad moves the slider.

Event.code for the num pad looks like Numpad7. There is no meta information on the event to determine if num lock is on.

Event.key accurately describes what is pressed. When Num Lock is on, we get 7. When Num Lock is off we get Home. Is it OK if we use Event.key for numpad keys?

jessegreenberg commented 1 year ago

Or we can just add numpad Event.codes to AccessibleValueHandler and have them always modify the slider. That is easier but a little less standard.

zepumph commented 1 year ago

The code is Numpad7. Is that standard for Home behavior? If we can feel confident saying something like NUM_PAD_HOME: 'Numpad7 in KeyboardUtils, then I think that is preferrable.

jessegreenberg commented 1 year ago

OK, a fix was pushed in the above commit. @zepumph and I looked at it together and I tested it on my Windows 10 machine with my numpad. @zepumph over to you, to cherry pick and verify in the next release.

zepumph commented 1 year ago

Looks great, let's reopen if QA has trouble in the sim-specific issue.