I am new with JQuery and want optimizing the following segment of code.
$('body').bind('keydown', function (e) {
var key = e.which;
if (key == 13) {
var inputs = $('.zeusTabEnter').find('input,textarea,select').filter(function () {
return !($(this).css('visibility') == 'hidden' || $(this).css('display') == 'none' || $(this).css('opacity') == '0')
&& $(this).is(':visible') && !$(this).is(':disabled') && $(this).attr('name').indexOf('ExpandColumn') == -1;
}).sort(function (a, b) {
return ((a.tabIndex > 0) ? a.tabIndex : 1000) - ((b.tabIndex > 0) ? b.tabIndex : 1000);
});
var typeCurrent = e.target.type;
if (typeCurrent != "image" && typeCurrent != "button" && typeCurrent != "submit" && typeCurrent != "reset") {
e.preventDefault();
e.stopPropagation();
var nIdx = inputs.index(e.target) + 1 == inputs.length ? 0 : inputs.index(e.target) + 1;
inputs.eq(nIdx).focus().select();
}
}
});