JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" name="asd" value="" />

JavaScript

function bind_input_keypress ($this) {	
    $($this).bind('input', function() {
        $($this).css('width',$($this).val().length*5.5+20);
    })
    $($this).bind('keypress',function(e) {
        /*  delete last extra... */
        if( e.keyCode == '8' && $($this).val()=='' ) { $('#extras b').remove(); }
        
        /* arrow up */
        if( e.keyCode == '38' ) {
            console.log('38 pressed');
        }
        /* arrow down */
        
        if( e.keyCode == '40' ) {
            console.log('40 pressed');
            ad_curr 	= $('.ad_selectbox .autocomplete ul li.active');
            
        }
    });
}
$('input').focus(function(){
    bind_input_keypress($(this));
})