JSFiddle - React, Tailwind, and code Playground

HTML

<input id="usuario" />

JavaScript

document.getElementById("usuario").onkeyup = function() {
    var code = (e.keyCode || e.which);

    // do nothing if it's an arrow key
    if(code == 37 || code == 38 || code == 39 || code == 40) {
        return;
    }
    
    this.value = this.value.replace(/[^\w\.]|\d/g, '');
};