-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use KeyboardListener instead of globalKeyStateTracker and custom listeners #1126
Comments
This one is for ?keyboardLocaleSwitcher. Since there is no view component to add a listener to, using the global EDIT: Similar story for phetioDevSaveLoad.ts |
I've attempted to follow the example provided, and it's not working in fourier-making-waves |
Can a static list of range keys be added that would parallel the functionality we previously got from |
Thanks @jbphet, I added functions for this in the above commit. They are exported from EnglishStringToCodeMap. |
Regarding #1126 (comment), after seeing the usage in phetsims/energy-forms-and-changes@3a708eb, I changed it a little. Functions and constants were moved to EnglishStringKeyUtils. |
I changed the ones assigned to me with the exception of |
Searching for
globalKeyStateTracker
.keydown:
, andkeyup:
I found this list of files that might be improved by using KeyboardListener:keydown
,keyup
) @jbphetkeydown
,keyup
) @jbphetkeyup
) @jbphet - (didn't update this one, here's why not).AccessibleNumberSpinner.ts@jessegreenberg - Not a good candidate for KeyboardListener. Adds other alt input listeners and replacing is more effort than it is worth. People will not go here to look for an example, this is an internal implementation.AccessibleValueHandler.ts@jessegreenberg - Same as AccessibleNumberSpinner.localeProperty.ts @samreid @zepumphnecessary usage of globalKeyStateTracker (no Node close by)phetioDevSaveLoad.ts @samreid @zepumph- necessary usage of globalKeyStateTracker (no Node close by)Display.ts @jessegreenberg- necessary usage of globalKeyStateTrackerAnimatedPanZoomListener.js @jessegreenberg- necessary usage of globalKeyStateTrackerImportant notes:
Examples:
globalKeyStateTracker
was often used to add support for global hotkeys. It is better to use KeyboardListener now for this case. Here is an example of the old style an an example switching to KeyboardListener.Old style
Using KeyboardListener
Often, a custom input listener was used for
keydown
andkeyup
events added to a particular Node. It might be better to use KeyboardListener for these for now.Old style
Using KeyboardListener
The text was updated successfully, but these errors were encountered: