Skip to content

OrbitControls eats cursor movement keyboard events for other input fields #15834

@kkolinko

Description

@kkolinko
Description of the problem

OrbitControls registers a listener for keydown events on a window and processes the events regardless of which input element has focus. When a user uses keyboard to move cursor in an input field, the events for the left and right arrow keys of keyboard are handled by OrbitControls and do not move the cursor. Better behaviour would be to ignore the event if some other input element has the focus.

Steps to reproduce, using current dev branch and examples:

  1. Open documentation (docs\index.html) and navigate to TorusGeometry document.
  2. In the iframe that displays an example of a torus, click on "THREE.TorusGeometry" button to open a properties editor for the object.
  3. Click on one of input boxes in the properties editor, e,g, on the value "10" for radius.
  4. Try to use your keyboard to move cursor position to the left and to the right in the input field.
    Expected behaviour: the cursor moves, as you press left or right arrows on your keyboard.
    Actual behaviour: the image of the torus moves.

The behaviour of r101 is to suppress all keydown events, regardless of key code (known as #15810, already fixed in dev). The behaviour of r100 was to move both the cursor and the object.

This issue could be fixed by either a) registering the keydown listener on the domElement instead of a window, b) filtering the event according to the actual value of document.activeElement. The "b)" way seems to provide better compatibility with older versions of three.js.

Three.js version
  • Dev
  • r101
Browser
  • Chrome
  • Firefox
OS
  • Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions