Ending routine when 'cursor' controlled by joystick hovers over image for a period of time

OS** (e.g. Win10): win 10,
PsychoPy version** (e.g. 1.84.x): 3
What are you trying to achieve?: Moving on to next trial when joystick hovers over an image for a period of time without a button click.

My task involves moving a ‘cursor’ (.png) with a joystick to 5 different targets on the screen. Each trial requires movement to a different target. Once the ‘cursor’ reaches the target the task moves on to the next trial. I have created the 5 static images and a ‘cursor image’ which can be moved with the joystick. The target order the subject moves the cursor to is controlled by a 6th image that alternates between the position of the 5 static images but is a different colour. This makes it look like the static images a changing colour. I have managed to end the routine when the cursor is over the target images using the code below but I want to adjust this so it ends only when the cursor is held over the target for period of 2secs. Any help on this is gratefully recieved.