Drag select with shift key pressed

I am using dragselectingTool to be able to drag select multiple nodes/links:


    this.diagram = $(go.Diagram, {
        ...
      dragSelectingTool: $(
        RealtimeDragSelectingTool,
        { isPartialInclusion: true, delay: 50 },
      )
        ...

But i want this drag selection should be possible only when shift key is pressed else (if shift not pressed) the default behavior (panningTool) should be apply to diagram.

I was trying to do it like so:

    const panningTool = this.diagram.toolManager.panningTool;
    panningTool.canStart = () => {
      if(!this.diagram.lastInput.shift && !this.diagram.selection.first()) {
        return true
      } else {
        go.DragSelectingTool.prototype.doActivate.call(dragSelectingTool);
      }
    }

But it not working properly.
Is it better solution?

Normally the DragSelectingTool takes precedence over the PanningTool, because of the order of those two tools in the ToolManager.mouseMoveTools list: https://gojs.net/latest/api/symbols/ToolManager.html#mouseMoveTools

So if you don’t want the DragSelectingTool or RealtimeDragSelectingTool to operate under certain conditions, you need to override its canStart method to return false in those conditions. Overriding PanningTool.canStart will let you control whether the PanningTool runs, but won’t help getting other tools that are earlier in the ToolManager.mouseMoveTools list to run.