checked a element is focused with its key pressed code example
Example: checked a element is focused with its key pressed
$(window).keyup(function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code == 9 && $('#detect:focus').length) {
alert('I was tabbed!');
}
});