How to simulate mouse held with key pressed?


#1

I’m trying to let the user replace mouse click/held with z or x.
In my keyPressedmethod I put this:
if (key == ‘z’ || key == ‘x’) {
mousePressed(ofGetMouseX(), ofGetMouseY(), 0);
mouseDragged(ofGetMouseX(), ofGetMouseY(), 0);
}
it works for single clicks but it doesn’t simulate dragging when I hold it down.


#2

keyPressed is only triggered once,
use in update:

if(ofGetKeyPressed(‘z’)||ofGetKeyPressed(‘x’)){
mousePressed(ofGetMouseX(), ofGetMouseY(), 0);
mouseDragged(ofGetMouseX(), ofGetMouseY(), 0);
}