Johnny MoCap
Johnny MoCap

Reputation: 41

Change behavior of "control" and "shift" keys in OrbitControls

Using a scene with OrbitControls and as far as I can tell by default pressing the ctrl and shift key reverts the left and right mouse movements. in my setup left mouse click rotatoes arounds the scene and right mouse clicks move around the 2d plain. how can I disable the ctrl and shift key reversing that?

a hack I found is to edit the controls mouseButtons back when the keys are pressed:

 this.controls.mouseButtons = {
      LEFT: shouldSwitch ? 2 : 0,
      MIDDLE: 1,
      RIGHT: shouldSwitch ? 0 : 2,
    };

using r141

Upvotes: 3

Views: 1048

Answers (1)

Mugen87
Mugen87

Reputation: 31076

OrbitControls does not allow disable the processing of "control", "shift" and "meta" keys. You would need a custom modification and remove the following two sections:

https://github.com/mrdoob/three.js/blob/f30599ed21818efbbffee6e923957616fd410016/examples/jsm/controls/OrbitControls.js#L905-L913

https://github.com/mrdoob/three.js/blob/f30599ed21818efbbffee6e923957616fd410016/examples/jsm/controls/OrbitControls.js#L927-L935

Changing the mouse button configuration (OrbitControls.mouseButtons) when one of the keys are pressed like suggested is also a valid solution.

Upvotes: 3

Related Questions