JSFiddle - React, Tailwind, and code Playground

HTML

<canvas id="canvas"></canvas>
<div id="output"></div>

JavaScript

var output = document.getElementById( 'output' );

// Using the nativeEvent field to determine which mouse button was clicked.
function onPress( event ) {
  var button = event.nativeEvent.button,
      which  = event.nativeEvent.which;

  console.log( 'button: '  + button +
               ', which: ' + which );
    
  if ( button === 0 || which === 1 ) {
    output.innerHTML += 'left<br>';
  } else if ( button === 1 || which === 2 ) {
    output.innerHTML += 'right<br>';
  }
}

function init() {
  var stage  = new createjs.Stage( 'canvas' ),
      square = new createjs.Shape(),
      output = document.getElementById( 'output' );

  square.graphics.beginFill( 'black' ).drawRect( 0, 0, 100, 100 );
  square.onPress = onPress;
    
  stage.addChild( square );
  stage.update();
}

init();