Problem with mouse input for an online task

Hi everyone, I am trying to create an online experiment where participants will see 12 unique line lengths and there will be a probe trial where they will reproduce lines by clicking, holding and dragging the mouse. I already have a code for the mouse input but it doesn’t work for online tasks I guess (
my_mouse = Mouse()
my_canvas = Canvas()
my_mouse.show_cursor(True)
my_mouse.set_pos(pos=(0.0,0.0))
my_canvas.show()

while True:
var.init_pos = my_mouse.get_pos()
button, start_pos, timestamp = my_mouse.get_click(timeout=20, visible=True)
var.start_resp = timestamp
if button is not None:
var.sx, var.sy = start_pos
ex, ey = start_pos

    while any(my_mouse.get_pressed()):
        (var.ex, var.ey), timestamp = my_mouse.get_pos()
        var.end_resp = timestamp
        my_canvas.clear()
        my_canvas.line(var.sx, var.sy, var.ex, var.ey)
        my_canvas.show()
    break)

I know that I am not supposed to use Python libraries for online studies but how else I can adjust that?

Thank you very much!