JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" id="fname">

<script>
    $(document).ready(function () {
        $('#fname').keydown(function (e) {
            var enteredValue = String.fromCharCode(e.which);
            alert(enteredValue) ;

            // Your Conditions Here
            if (enteredValue === "4")
                e.preventDefault();
        });
    });
</script>

JavaScript

45545454