Skip to content

examples : use event.code instead of event.keyCode#21056

Merged
mrdoob merged 2 commits intomrdoob:devfrom
felixmariotto:dev-key-events-fix2
Jan 12, 2021
Merged

examples : use event.code instead of event.keyCode#21056
mrdoob merged 2 commits intomrdoob:devfrom
felixmariotto:dev-key-events-fix2

Conversation

@felixmariotto
Copy link
Contributor

following #21055

Issue : the pointerlock example, FirstPersonControls and FlyControls checked the keyCode property of the keydown and keyup events, which means it was bound to characters. Some keyboard layouts, like the French one displayed bellow, don't map the WASD keys at the same place, whereas we actually play with the same keys as everybody, only these keys represent different characters.

Screenshot_1

This PR continues to fix this issue in various examples by using event.code, which is layout-independant.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 11, 2021

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 11, 2021

Since the engine has not officially stopped support for IE11, it's worth mentioning that using KeyboardEvent.code does not work in this browser.

https://caniuse.com/keyboardevent-code

This is not an issue for #21055 since IE11 does not support Pointer Lock API either.

@mrdoob mrdoob added this to the r125 milestone Jan 12, 2021
@mrdoob mrdoob merged commit c6239d2 into mrdoob:dev Jan 12, 2021
@mrdoob
Copy link
Owner

mrdoob commented Jan 12, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants