JSFiddle - React, Tailwind, and code Playground

HTML

Hold a letter key down in this textbox >>
<input id="inputField" type="text" />
<button type="button" id="clear">clear logged events</button>
<br/>
<br/>Events:
<br/>
<br/>
<div id="output" />

JavaScript

function debounce(func, interval) {
    var lastCall = -1;
    return function () {
        clearTimeout(lastCall);
        var args = arguments;
        lastCall = setTimeout(function () {
            func.apply(this, args);
        }, interval);
    };
}

$("#inputField").on("keypress", debounce(function (event) {
    $("div#output").append("key pressed <br/>");
}, 150));

$("#clear").on("click", function (event) {
    $("div#output").html("");
});