JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" />

JavaScript

$(function(){
    $("input").keyup(function(){
        var $this = $(this);
        if ((($this.val().length+1) % 5)==0){
            $this.val($this.val() + " ");
        }
    });        
});