I have the following line of jquery which reacts to any key up event in any text input on a form. It then runs a function called processPrimarySearch
:
$('#primarySearch input[type="text"]').on('keyup', this, processPrimarySearch);
This works, but I want to adapt it so keyup
ignores a tab key press as described here: Keyup event behavior on tab
I can't work out how to re-write this as I don't understand how to pass this
before calling processPrimarySearch
. For example I have the following but it doesn't work and I don't understand what I'm supposed to write to make it work:
$('#primarySearch input[type="text"]').on({
"keyup": function(e) {
if (e.which != 9) {
// No reference to 'this'!
processPrimarySearch();
}
}
});
function processPrimarySearch() {
// ...
}