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 throttle(func, milliseconds) {
    var lastCall = 0;
    return function () {
        var now = Date.now();
        if (lastCall + milliseconds < now) {
            lastCall = now;
            return func.apply(this, arguments);
        }
    };
}


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

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