-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add ability to listen for keyboard events outside of the PDOM #1048
Comments
This is working well. aqua tests passing.
This isn't working. When the browser is active but focus isn't in the PDOM, listeners have to be on document.body to receive input. And when this happens, clicking on the sim is sending 'click' events through the PDOM input system. I don't think we want scenery to dispatch 'click' events from pointer input. |
But scenery tests are failing, would need to investigate. But @zepumph and I also just discussed and he recommended another approach: |
I don't see this working yet. On document.body, there is no target in the scene graph and therefore no trail to dispatch to. |
The way to do a "global" event a la dispatch would mean something like getting all leaf trails in the scene graph and dispatching a SceneryEvent to all of them. |
Is possible, but feels excessive. MAL has 209 leaf trails and we would be dispatching to all of these with bubbling every event. This also isn't the correct behavior yet. A node that has more than one leaf trail through it will receive "global" events multiple times as we dispatch an event to each one. Would be good to brainstorm a bit more, but I am coming back to the first solution in #1048 (comment). |
I pushed the change to attach the KeyStateTracker to the body so that it can be used for keyboard events outside of the PDOM. Unit tests and aqua fuzzing is passing. I am not sure if this is the best solution yet, I would like to discuss with @zepumph again at the next a11y-dev meeting. |
Changes to PDOMPointer that reference this issue in their commit message are causing CT failures for multiple sims, see phetsims/scenery-phet#605. |
Thanks for pointing out, the error is actually related to #921. |
Reviewed again with @zepumph on 10/27/2020 -
One of the reasons to move the KeyStateTracker out of Display is that then we can avoid having all sims create this listener unless they need it. Since all Sims use a KeyboardFuzzer, we are going to avoid using globalKeyStateTracker there, and it will create its own KeyStateTracker instance. |
We ran into this while working on #1119, I'll take this on. |
@jessegreenberg please review. I tested with MAL global keys, as well as poking around with zooming on my own, fuzzing, and PhET-iO studio. Anything else here? |
globalKeyStateTracker looks great, as do its usages. Thanks! |
For phetsims/scenery-phet#571. We want to be able to listen to keyboard events when focus is outside of the PDOM.
One way to do this is to listen for events is to attach the Display.keyStateTracker to document.body (See KeyStateTracker.attachToBody).
Another way to do this would be to attach DOM input listeners for PDOM to Display.domElement instead of Display.accessibleDOMElement.
Maybe there are other ways too, I haven't thought through the implications yet.
The text was updated successfully, but these errors were encountered: