Open jbphet opened 2 years ago
@matthew-blackman and I experiemented with this a bit, just in a basic case where you can focus the keypad and listen to number keys, it worked well enough that I'll put the patch in here for next time:
@zepumph and I worked on this in a patch and got it to the point where one can type into the keypad if it is in focus. The solution is still a bit hacky and not complete but it seems to work based on a first pass. Patch below:
@zepumph and I discussed adding full keyboard support to Keypad keyboard listeners, as well as exporting/importing the OneKeyStroke type to Kaypad.ts. Patch with these changes is as follows:
We got a first pass in https://github.com/phetsims/scenery-phet/issues/790, let's see if we want to use it in Projectile motion.
Keyboard input appears to be working in Projectile Motion when supportsInteractiveDescription is turned on. It requires manually focusing on the keypad.
Unassigning @jbphet as we will pick this back up when ready to implement the updated Keypad into Projectile Motion.
Lots of good work over in https://github.com/phetsims/scenery-phet/issues/790!
The "Lab" screen in this sim supports the ability to specify a "Custom" projectile, and then enter values for several parameters such as mass, diameter, etc. Currently, the user has to interact with the keypad in the sim to enter these values, and can't just type the numbers on their keyboard. Part of the reason for this behavior is that we didn't want to make the inputs real HTML input fields, because that caused the keyboard to pop up on devices like iPads. With the recent advances that we've made on keyboard input listeners (see https://github.com/phetsims/scenery/issues/1445), it should now be possible to add a global key listener that would support entering numeric values.
Here is a screenshot from the Lab screen that shows the state where the values can be entered:
During the 10/27/2022 developer meeting, we discussed adding numeric entry to several sims, and decided to set up this particular issue as a sort of "pilot project" for handling numeric entry from the keypad. Some of what is done here may need to in common code to make it easier to add the same or similar functionality to other sims.