Good day,
Im wondering if we can use keyboard shortcut F2 and F3 to execute function. If got, maybe can share your code to me. Below my idea to make the shortcut key. i've tried but not functioning.
$("#ENQUIRY_VIEWMETER").keypress(function(event) {
if(event.which == 113) { //F2
updateMtr();
} else if(event.which == 114) { //F3
resetView();
}
});
p/s : or maybe need some amendment on my code. :)
Try using the keydown event instead of keypress. The keydown event tells you which actual key was pressed, but keypress is more about what character resulted.
And return false so that the default browser behaviour (if any) for those keys doesn't go ahead (don't return false for other keys).
$("#ENQUIRY_VIEWMETER").keydown(function(event) {
if(event.which == 113) { //F2
updateMtr();
return false;
}
else if(event.which == 114) { //F3
resetView();
return false;
}
});
Demo: http://jsfiddle.net/TTrPp/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With