-
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
Event.keyCode is deprecated #1053
Comments
Thanks for bringing up. MDN recommends But it looks like |
We discussed this today and both agreed that it is the right thing to do to move away from deprecated
It isn't yet clear how this will impact internationalization since We feel that this can be addressed at medium priority. |
Note that KeyboardFuzzer currently runs on keyCode, I was using Event.key for RatioInteractionListener.js to try it out, and it isn't set up to work right now. |
I think of above as a workaround until we add support for Event.key in KeyboardFuzzer. @jessegreenberg do you want this in its own issue? |
Thats OK, thanks! Ill take a look as part of this issue. |
PhET is about to drop support for IE11, and so I wondered if event.code should be used instead of event.key. But there is another reason not to use event.code, from MDN:
|
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key Indicated that certain keys might be different for Edge, so I was wondering if we would have to so something different on that platform. But https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values shows that the differences were for versions older than 16, so we are still good to go. |
I think we should raise the priority on this because of #1145. I'll assign myself. |
I see 95 usages of cased |
Today during a11y dev meeting, @jessegreenberg and I decided that we want to see Furthermore, we realized that for i18n, we can have translators translate the key strings that we use, and then it will reflect the layout that they use in their keyboards (assumption here that the layout is based/typical of a locale). But that is for future us to handle. Onward!! |
keyCode has been almost entirely removed from the project in exchange with Event.key. Summary of work:
Main questions from this work:
I tested by making sure that keyboard input worked for a variety of types, including common code and sim-specific implementations that utilized certain keys. Aqua phet brand and fuzzBoard were both passing, so I went for it! Note that I couldn't really test PhET-iO playback support for keyboard and focus because of https://github.com/phetsims/phet-io/issues/1693 Over to @jessegreenberg with a review that should block publication. |
I went through some more usages of Event.key, and took a look at the above commits. I found quite a few spots where Event.code wasn't being used. Many were outside of the sim (like in tools/PhET-iO wrappers/etc). I feel like we should have a consistent approach across the project, so I tried to change all I could.
Thanks for doing this conversion. |
We saw something in phetsims/geometric-optics#68 that may be related? @zepumph and @jessegreenberg can you please have a look? |
OK thanks - I am pretty sure it is caused by something else and opened #1249 for that issue. |
This reverts commit 920de84.
I updated the usage in sun and tested, good catch.
In #1249 I updated the portion of scenery/js/accessibility/KeyStateTracker.js Lines 162 to 183 in 2660c9e
and I don't know how to make it better. From
Looks very nice, thanks. @zepumph reassigning to you to review this comment, but the remaining work in KeyStateTracker may be for a dev meeting. |
Yes, that makes plenty of sense. Thanks for explaining. This is the stuff of legends. Thanks for doing that.
|
Good idea, done above. Back to you to review again. |
Looks good. Anything else here? |
Thanks for reviewing again, I think we are back on track for this issue. |
While working on phetsims/ratio-and-proportion#44, I found over at https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode that keyCode is deprecated. We use this a ton, and it didn't seem totally clear how we should go about handling this. Looking at https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent is not uplifting, as there doesn't seem to be an obvious replacement. @jessegreenberg, let's talk about this tomorrow.
The text was updated successfully, but these errors were encountered: