JSFiddle - React, Tailwind, and code Playground

HTML

<textarea style="width:100%">function should fire when the next input is tabbed into or clicked (focused), but not when changing browser tabs</textarea>
<input>

JavaScript

var times = 0, foc=true;

$(window).on('focus', function() {
    foc = false;
    setTimeout(function() {foc=true}, 200);
});

$('input').on('focus', function() {
    if (foc || times===0) {
        times ++;
        $(this).after('<br>Focused '+times+' times');   
    }
});