Adjusting code for mouse interaction for an online line reproduction task

I need to write a code in for an online line reproduction task. In the reproduction trial, I want participants to reproduce only holding down the mouse to reproduce the lines and when they stop holding down their response will be saved. I tried to come up with this code but since it should be online, I am not sure if these will be compatible. How can I adjust the code for an online experiment?

Thanks!!