code: function (event) {
        var xPos, yPos, rect;
        rect = this.canvas.getBoundingClientRect();
        if (event.originalEvent)
            event = event.originalEvent;
  
        // Touch event
        if (event.type.indexOf('touch') !== -1) { // event.constructor === TouchEvent
          xPos = event.touches[0].clientX - rect.left;
          yPos = event.touches[0].clientY - rect.top;
        }
        // Mouse event
        else {
          xPos = event.clientX - rect.left;
          yPos = event.clientY - rect.top;
        }
        return {
          x: xPos,
          y: yPos
        };
      }
docs: Get the position of the mouse/touch