phetsims / fourier-making-waves

"Fourier: Making Waves" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 3 forks source link

Change hotkey to fire on keydown. #216

Closed pixelzoom closed 2 years ago

pixelzoom commented 2 years ago

From https://github.com/phetsims/scenery/issues/1335:

BASE uses KeyboardDragListener addHotKeys. And these callbacks seem to fire on keydown.

In Fourier Making Waves, I was advised to fire hotkeys on keyup, by adding listeners to globalKeyStateTracker.keyupEmitter. See for example WaveGameLevelNode line 263.

In https://github.com/phetsims/scenery/issues/1335#issuecomment-1004395806, @jessegreenberg said:

I think hotkeys should fire on down. I noticed that browser hotkeys all fire on down as well (for example, all of these: https://support.google.com/chrome/answer/157179?hl=en&co=GENIE.Platform%3DDesktop).

I wonder if keyup was recommended because it was a natural way to prevent the hotkey listener from firing every down event? But whatever is handling the hotkeys should prevent this.

So I will change this sim to fire on keydown. @arouinfar FYI.

pixelzoom commented 2 years ago

Done in master and 1.0 branches. I'm planning to deploy this with the MR for https://github.com/phetsims/fourier-making-waves/issues/215.

pixelzoom commented 2 years ago

Tested in 1.0.4-rc.2, deployed in 1.0.4. See https://github.com/phetsims/fourier-making-waves/issues/215#issuecomment-1005056771.

Closing.