How to hold SHIFT key and mouse move?


I am trying to reproduce fallowing behavoiur using Robot.js class:

  1. press SHIFT key
  2. MouseDown on an element
  3. MouseMove to some other location
  4. MouseUp

As far my code is not working, it behaves like shift it not held. Can anyone know how I can simulate shift down with robot.js?

const dragdrop = { sourceDiagram: this.canvasDiagram, targetDiagram: this.canvasDiagram };
const node = this.canvasDiagram.findNodesByExample({name:}).first();
const loc =;
this.robotTest.keyDown(16); //tried also this.robotTest.keyDown(16, 0, {shift:true}); 
this.robotTest.mouseDown(loc.x, loc.y, this.canvasDiagram.toolManager.dragSelectingTool.delay + 50, dragdrop); this.robotTest.mouseMove(,, this.canvasDiagram.toolManager.dragSelectingTool.delay + 200, dragdrop);
this.robotTest.mouseUp(,, this.canvasDiagram.toolManager.dragSelectingTool.delay + 200, dragdrop); 


You do need to pass the { shift: true } option explicitly.

How do you know that the code is not working as if InputEvent.shift were true?

@walter thank you!

In our case we have fallowing steps:

  1. have 2 “snapped” nodes
  2. press shift key
  3. click on one node and move it

It should resulted in unsnapped nodes.

I think the code is not working becuase when I run it, the result is not unsnapped nodes but both nodes snapped and moved (which happens when you will do steps above without step 2).

Is there any chance I could check if shift key is still down during mouse move?

You need to pretend to hold down the Shift key for all of the mouse events during the whole operation. That means including shift: true in the options for every mouse event.

@walter Thank you a lot. I will try :)

@walter great it works! thank you :)