Help tracking mouse, drawing equal spaced pnts

I’m trying to track mouse movement and save a series of points at equal spacing as the user moves the mouse.

Could anybody offer a way to do this or sample code? Cant seem to find any examples and being new to this having trouble figuring out how to go about it.