OrbitControls keydown events not firing
See original GitHub issueDescribe the bug
the keydown event is attached to the dom node as should be, but when you use the arrow keys no event is fired. I can see in the PR #17819 that you added the following code:
if ( scope.domElement.tabIndex === -1 ) {
scope.domElement.tabIndex = 0;
}
but in the latest release r123, this code is no longer there. If I re-add the code above the keydown events work as expected. After some digging I can see in #20617 this issue is known, but i’ve already written this bug so at least it’s visible to others.
If I understand right, is it that the canvas isn’t focussed so the keydown events don’t fire? I’m happy to work on a PR to fix this.
To Reproduce
Steps to reproduce the behavior:
- Go to - https://threejs.org/examples/?q=controls#misc_controls_orbit
- try use the arrow keys
Expected behavior
The keydown events should fire moving the camera.
Platform:
- Device: [Desktop, Mobile] desktop
- OS: [Windows, MacOS, Linux, Android, iOS] macOS
- Browser: [Chrome, Firefox, Safari, Edge] chrome/firefox
- Three.js version: r123
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:21 (10 by maintainers)
Top Results From Across the Web
keydown doesn't work in threejs canvas, OrbitControls on
The element , i.e., input and button is focussed on clicking but input doesn't register any key stroke. When I checking in the...
Read more >Orbitcontrols default keyboard events stopped working ...
OrbitControls keydown events not firing ... Describe the bug the keydown event is attached to the dom node as should be, but when...
Read more >Three.js OffscreenCanvas
The OrbitControls attach event handlers to window to get keyboard events. Not sure that's the right place to attach them but that's beyond...
Read more >Add Controls in ThreeJs | OrbitControls in ThreeJs - YouTube
Controlling objects in ThreeJs is a pretty important topic so by doing that we can create a pretty good interactive 3D view, ...
Read more >Orbit controls for threejs from the project itself
It would not be that hard to implement some camera controls for a three.js ... of a camera with the mouse, keyboard, and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@TiagoCavalcante
OrbitControls
listens for arrow keys, not WASD.Do this:
Yeah, but I think it’s not too bad and teaches the user about pointer events.
Also, code editors also gave me issues when doing this:
They would complain that
controls
is not used and had to do this:Which was always weird 😅