JSFiddle - React, Tailwind, and code Playground

by David Buzatto

HTML

<input id="foo" value="1"/>

JavaScript

// setas

$( "#foo" ).on( "keydown", function(evt){
    
    var $this = $(this);
    
    switch( evt.keyCode ) {
        
        case 38: // cima
        case 39: // direita
            $this.val( parseInt( $this.val() ) + 1 );
            break;
            
        case 37: // esquerda
        case 40: // baixo
            $this.val( parseInt( $this.val() ) - 1 );
            break;
        
        default:
            evt.preventDefault();
            break;
    }
    
});