Reputation: 121
I have problem with jQuery onKeyPress()
execution on IE9.
On Mozilla everything works fine, but IE9 makes problems.
When I set focus to a text area and press F4, I call a function to show div. That works fine in Mozilla, but in IE9 it does not. I tried many combinations with onKeyDown
/onKeyUp
but I didn't succeed.
Could you please help with a tested solution?
My code is:
$('#textBox).on('keypress', foo);
function foo() {
var KEYCODE_F4 = 115;
if (event.which == KEYCODE_F4) {
someMethod();
}
}
Upvotes: 1
Views: 593
Reputation: 2821
I think
function foo() {
...
}
Should be
function foo(event) {
...
}
As noted by Barry Chapman you are also missing an '
on your $('#textBox')
Upvotes: 2
Reputation: 6780
I hope its not because of this:
$('#textBox).on('keypress', foo);
^-missing a '
Should be:
$(document.body).on('keypress', '#textBox', function(event) {
var KEYCODE_F4 = 115;
if (event.which == KEYCODE_F4) {
someMethod();
}
});
Upvotes: 0