JSFiddle - React, Tailwind, and code Playground

HTML

<input>

JavaScript

$("input").on("keypress", function(e) {
    if (e.which === 32 && !this.value.length)
        e.preventDefault();
});