OrbitControls/TrackballControls: Replace event.keyCode with event.code.#21409
OrbitControls/TrackballControls: Replace event.keyCode with event.code.#21409mrdoob merged 24 commits intomrdoob:devfrom puxiao:patch-1
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 |
|
Don't worry about the commits. @mrdoob can squash/merge so the commits are all combined into a single one. |
| 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.
How does this change affect french, ... keyboards?
|
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.keyCoderead-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...