If you use the jquery library you can use the .mousemove(handler)
function which looks something like this
$( "#target" ).mousemove(function( event ) {
var msg = "Handler for .mousemove() called at ";
msg += event.pageX + ", " + event.pageY;
$( "#log" ).append( "<div>" + msg + "</div>" );
});
Target is the id of the html element you want to track the mouse within and log is where the result is displayed
Also to track cursor you could use the .keypress(handler)
it works similar to above code. Details can be found on the jquery api site.
solved javascript follow html input fields [closed]