JSFiddle - React, Tailwind, and code Playground

HTML

<div id='button'>button</div>

JavaScript

$('#button').mousedown( function() {
    $(document).mousemove(function() {
        // only fires when mouse is down and moving
        $('body').append('hi<br>');
    });

    $(document).mouseup(function() {
        $(this).unbind();  // unbind events from document
    });
});