JSFiddle - React, Tailwind, and code Playground

by asif097

HTML

<input type="text" maxlength="1" class="small" />
<input type="text" maxlength="1" class="small" />
<input type="text" maxlength="1" class="small" />
<input type="text" maxlength="1" class="small" />

CSS

.small {
    width:14px;
    text-align:center;
}

JavaScript

$(".small").on('keyup', function (e) {
    if(e.keyCode == 8){ /* backspace is 8 */
        $(this).prev('.small').focus();
    }else{
        $(this).next('.small').focus();
    }
});