I normally create one mouse component (called mouse) in the first routine that needs it and then refer back to the mouse (no new mouse components) for the rest of the experiment.
I put the above code into a code component within my very first routine of the experiment (instructions routine) because I thought it would help with converting everything to JS.
After that, the only time the mouse is mentioned in a code component is when I’m checking for responses during the trial, i.e.: