JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" />
<input type="text" id="detect" />
<input type="text" id="detect2" />

JavaScript

$(window).on('keyup', function(event){
    if(event.keyCode == '9'){
        
      getFocused(event);
    }

})
var focused = 0;
function getFocused(e){
var ida =  $(':focus').eq(0).prop('id');
    if(ida=='detect' && focused==0){
        focused = 1;
        console.log(e);
    }
}