-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
OrbitControls/TrackballControls: Replace event.keyCode with event.code. #21409
Conversation
issue: - **Description** The deprecated **`KeyboardEvent.keyCode`** read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key. https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode so... ```diff // The four arrow keys - this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 }; + this.keys = { LEFT: 'ArrowLeft', UP: 'ArrowUp', RIGHT: 'ArrowRight', BOTTOM: 'ArrowDown' }; function handleKeyDown( event ) { - switch ( event.keyCode ) - switch ( event.code ) } ```
Please always modify the code in Besides, it would be great if you change Sidenote: |
@Mugen87 OK, KeyboardEvent.key work in IE. |
I don't think it's necessary to honor IE anymore. I've just noted it for clarification reasons. |
@Mugen87 How to modify OrbitControls.d.ts - keys: { LEFT: number; UP: number; RIGHT: number; BOTTOM: number; };
+ keys: { LEFT: string; UP: string; RIGHT: string; BOTTOM: string; }; TrackballControls.d.ts - keys: number[];
+ keys: string[]; |
https://raw.githack.com/puxiao/three.js/patch-1/examples/index.html Two examples configure |
@Mugen87 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Don't worry about the commits. @mrdoob can squash/merge so the commits are all combined into a single one. |
@@ -29,7 +29,7 @@ THREE.TrackballControls = function ( object, domElement ) { | |||
this.minDistance = 0; | |||
this.maxDistance = Infinity; | |||
|
|||
this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ]; | |||
this.keys = [ 'KeyA' /*A*/, 'KeyS' /*S*/, 'KeyD' /*D*/ ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this change affect french, ... keyboards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #21056 (comment)
Thanks! |
Brings three-stdlib up to date with three: mrdoob/three.js#21409
Brings three-stdlib up to date with three: mrdoob/three.js#21409
Brings three-stdlib up to date with three: mrdoob/three.js#21409
Related issue: Related #21056.
Description
The deprecated
KeyboardEvent.keyCode
read-only property represents a system and implementation dependent numerical code identifying the unmodified value of the pressed key.https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
so...