Access to the right click using the tag.

You are looking for how to do this everywhere, and there is almost no documentation for three. js. Does anyone know how I can access a right click? This is what I have now:

function onDocumentMouseDown(event) { mouseDown = true; event.preventDefault(); mouseX = event.clientX - windowHalfX; mouseY = event.clientY - windowHalfY; document.addEventListener('mousemove', onDocumentMouseMove, false); document.addEventListener('mouseup', onDocumentMouseUp, false); document.addEventListener('mouseout', onDocumentMouseOut, false); } 

And this works great for what I use it for, but this event is for left click, middle click and right click. How to isolate a right-click event so that left-click and right-click can have different effects?

+4
source share
1 answer

event has a button property. You can handle this as follows:

 switch ( event.button ) { case 0: // left break; case 1: // middle break; case 2: // right break; } 
+11
source

All Articles