# How to use both OrbitControls and canvas mousedown

**URL:** <https://discourse.threejs.org/t/how-to-use-both-orbitcontrols-and-canvas-mousedown/27328>\
**Category:** Questions\
**Tags:** orbit-controls\
**Created:** [June 18, 2021, 10:07am UTC](https://discourse.threejs.org/t/how-to-use-both-orbitcontrols-and-canvas-mousedown/27328 "2021-06-18T10:07:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![twisted](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@twisted](https://discourse.threejs.org/u/twisted)\
**Post date:** [June 18, 2021, 10:07am UTC](https://discourse.threejs.org/t/how-to-use-both-orbitcontrols-and-canvas-mousedown/27328/1 "2021-06-18T10:07:49Z")

</div>

In my application I want to use OrbitControls to rotate and dolly, although with the mouseButtons changed so as to leave left mousedown free.

Left mousedown I want to eventually use for selecting objects in the scene.

Problem is that once I create an OrbitControls, even though I’m leaving the left mouse button unused, the canvas event listener is never called.

```javascript
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>orbit-and-onclick-01</title>

  <script type='module'>

    import * as THREE from '../lib/three-js-129/build/three.module.js';
    import {OrbitControls} from '../lib/three-js-129/examples/jsm/controls/OrbitControls.js';

    let canvas, camera, renderer, scene; 

    function initLight(){
      const light = new THREE.DirectionalLight(0xFFFFFF, 1);
      light.position.set(-1, 2, 4);
      scene.add(light);
    }

    function initCamera(){
			camera = new THREE.PerspectiveCamera( 45, 2, 0.1, 100 );
			camera.position.set( 0, 0, 8 );
    }

    function render(){
      renderer.render(scene, camera);
      requestAnimationFrame(render);
    }

    function addTorus(scene){
			const torusGeometry = new THREE.TorusGeometry( 1, 0.3, 16, 100 );
			const torusMaterial = new THREE.MeshPhongMaterial( { color: 0xffaaff } );
			const torus = new THREE.Mesh( torusGeometry, torusMaterial );
			torus.receiveShadow = true;
			torus.castShadow = true;
			scene.add( torus );
    }

    function doMouseDown(){
      console.log('mouse down');
    }

    window.onload = function(){   
      canvas = document.getElementById('canvasId');
      scene = new THREE.Scene();
			renderer = new THREE.WebGLRenderer({canvas: canvas});
      initLight();
      initCamera();
      new OrbitControls(camera, canvas).mouseButtons = {
	      MIDDLE: THREE.MOUSE.DOLLY,
	      RIGHT: THREE.MOUSE.ROTATE
      }
      canvas.addEventListener('mousedown', doMouseDown);
      addTorus(scene);
      requestAnimationFrame(render);
    }

  </script>
</head>
<body>
  <canvas id='canvasId'></canvas>
</body>
</html>

```

Is there a way of getting getting OrbitControls to pass an unused mouse event through to the canvas doMouseDown event handler?

Or some other way of accomplishing this?

[https://mytestpages.com/three/orbit-and-onclick-01.html](https://mytestpages.com/three/orbit-and-onclick-01.html)

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [June 18, 2021, 10:24am UTC](https://discourse.threejs.org/t/how-to-use-both-orbitcontrols-and-canvas-mousedown/27328/2 "2021-06-18T10:24:04Z")

</div>

This is a know issue and should be solved with the next release `r130`. More information here:

> <https://github.com/mrdoob/three.js/issues/21889>
>
> \*\*Describe the bug\*\*
> 
> Unable to trigger wrapper element events when set orbitc…ontrols enabled
> 
> \*\*To Reproduce\*\*
> 
> Steps to reproduce the behavior:
> 1. Create 3d scene, and add orbitcontrols on it
> 2. Bind some events on canvas wrapper element
> 3. Wrapper element will trigger only when set orbitcontrols disabled
> 
> 
> \*\*\*Live example\*\*\*
> https://codesandbox.io/s/suspicious-wilson-brekt?file=/src/App.js
> 
> \*\*Expected behavior\*\*
> Canvas wrapper element events will trigger whatever orbitcontrols is enable or not 
> 
> 
> \*\*Platform:\*\*
> 
> - OS: \[MacOS\]
> - Browser: \[Chrome, Firefox, Safari, Edge\]
> - Three.js version: \[0.128.0\]

---

<div class="post-metadata">

**Author:** ![twisted](https://avatars.discourse-cdn.com/v4/letter/t/f04885/32.png) [@twisted](https://discourse.threejs.org/u/twisted)\
**Post date:** [June 18, 2021, 1:32pm UTC](https://discourse.threejs.org/t/how-to-use-both-orbitcontrols-and-canvas-mousedown/27328/3 "2021-06-18T13:32:05Z")

</div>

Thanks.

Until r130 is ready, using your updated OrbitControls.js in my code does what I need:

[https://mytestpages.com/three/orbit-and-onclick-03.html](https://mytestpages.com/three/orbit-and-onclick-03.html)
