-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
OrbitControls: get keydown events from scope.domElement #16676
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
Conversation
Binding to window has issue that keys events are received even when not meant for OrbitControls. It also means arrow keys can be blocked since when an arrow key is pressed the OrbitControls call event.preventDefault so that the page does not scroll. Binding to scope.domElement is either the document if no element is passed in (in which case the same issue as mentioned above exists) but if you pass in an element like the canvas itself then you can receive keyboard events on other elements providing a workaround when needed to the issue mentioned above.
|
Can you please rebuild the module file via If everything is fine, I vote to merge this PR. |
|
I have tested this change on my local computer. While the fiddle from #16597 is fixed, the behavior of the official example (https://threejs.org/examples/#misc_controls_orbit) changes. Right now, when you open it you can directly use the key controls. With this PR, you have to click on the canvas first so it has the focus. |
|
Can https://www.w3schools.com/jsref/met_html_focus.asp be used for that example? Perhaps with an optional constructor param |
I don't think it's worth to modify the ctor just for this use case. Instead, I would accept this change in behavior since adding event listeners to However, the PR needs an update: It's not necessary anymore to test for if ( scope.domElement.tabIndex === - 1 ) scope.domElement.tabIndex = 0; |
|
Closing. Feel free to reopen the PR when my suggested changes are implemented. |
Why was this PR closed? |
|
I think it's because we no longer support |
|
No, because this PR relates to this line, where a global listener is defined, irrespective of the three.js/examples/js/controls/OrbitControls.js Line 1139 in 8fcc7b8
|
Correct. Line 940 needs a fix that I've posted here: #16676 (comment). I've closed the PR since @greggman did not react on the feedback. @EliasHasle Would you like to perform this change? |
|
Hm, I still think this is @greggman's "territory", so to speak. You gave him "only" a week to answer, whereupon you closed the PR. I think the PR is still just as relevant. And a one week delay for something not life-critical is not that much. (Compare to the delays in handling PRs. Some are years old.) |
|
(So much for "territory"...) |
|
I've also requested a rebuild of the module files here (with no reaction): #16676 (comment) So I think it's okay if somebody else works on the issue. |
Binding to window has issue that keys events are received
even when not meant for OrbitControls. It also means arrow
keys can be blocked since when an arrow key is pressed
the OrbitControls call event.preventDefault so that the
page does not scroll.
Binding to scope.domElement is either the document if no
element is passed in (in which case the same issue as mentioned
above exists) but if you pass in an element like the canvas
itself then you can receive keyboard events on other elements
providing a workaround when needed to the issue mentioned
above.
fixes #16597