JSFiddle - React, Tailwind, and code Playground
HTML
<input type="number" placeholder="YYYY" name="year" class="char-4" inputmode="numeric" pattern="[0-9]*" data-numeric-input="" maxlength="4" max="9999">
JavaScript
$("input").bind('keypress', function() {alert("hi");});