JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" placeholder="Type anything">
JavaScript
$('input').keypress(function(e) {
if (e.key !== '1') return false;
});
<input type="text" placeholder="Type anything">
$('input').keypress(function(e) {
if (e.key !== '1') return false;
});