phetsims / sun

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

Improve alt input press and hold behavior for buttons #893

Open jessegreenberg opened 1 month ago

jessegreenberg commented 1 month ago

It is unfortunate that all buttons have a press-and-hold behavior with the Enter key. For example, tab to a ResetAllButton and press and hold the Enter key; it fires continuously, spamming the reset action and repeatedly playing the sound.

Buttons fire on the click event, which is handled differently by user agents, browsers, and operating systems. It is most accessible and simple if we continue firing buttons in response to the click event without special behavior for keyup/keydown events.

Is there a way we can improve this for PhET sims while staying compatible with assistive devices?

Just brainstorming – one possible solution could be to add a time-based throttle, only allowing click events at a certain interval. This could be customized with an option.

From https://github.com/phetsims/sun/issues/796.

terracoda commented 1 month ago

So the exact difference is that

There are many examples where this repeat fire behavior is not desirable. It can cause color and animations to flash and sounds and description to repeat. There may be specific interaction contexts where this behavior is desirable. For example, in Projectile Data Lab, the Launch button is accompanied by a radio button group for Single or Continuous firing of objects. Might the repeat-fire behavior be useful in this case where both a single and continuous option are desired?

@jessegreenberg, I like the idea of a time-based throttle option.