Tüm kod, hiçbir yabancı aramaların kontrol sahibi Örtmek $(input).focus()daha setFocus().
Global bir değişken kullanmak benim için doğru bir yoldur.
var globalIsHuman = true;
$('input').on('focus', function (){
if(globalIsHuman){
console.log('hello human, come and give me a hug');
}else{
console.log('alien, get away, i hate you..');
}
globalIsHuman = true;
});
// alien set focus
function setFocus(){
globalIsHuman = false;
$('input').focus();
}
// human use mouse, finger, foot... whatever to touch the input
Bazı uzaylılar hala $(input).focus()başka bir gezegenden aramak istiyorsa . İyi şanslar veya diğer cevapları kontrol edin