forked from cruise-automation/webviz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix keyMap behavior by using event.code; add shiftKeys (cruise-automa…
…tion#71) cruise-automation#56 switched from [`e.keyCode`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode) to [`e.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key), which caused a problem where keys could get "stuck" down. For example, after `press A, press Shift, release A, release Shift` the CameraListener would think the A key was still pressed. `e.key` is explicitly supposed to take into account modifier keys such as shift & option, because it represents the character that would be typed when pressing the key, so using it to track key-up/down state doesn't work well. In this PR I'm switching to [`e.code`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code) instead, which is a more newly standardized property that is independent of keyboard layout (it always works as if the layout were QWERTY) and intended to be used when you care about the key's position rather than the character it represents. This PR also ignores key repeats, removes an unused `onKeyDown` prop, and fixes a bug where the 1/10 magnitude adjustment for the shift key was applied twice, which made keyboard movement with the shift key even slower than intended. Also adds a `shiftKeys={/*boolean*/}` to disable shift key modifiers.
- Loading branch information
Showing
4 changed files
with
62 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters