I want to be able to have a trigger on keypress for %. So far, I have this:
$(iframeDocument).find('body').on('keydown', function(event) {
if (event.which == 53) {
alert("% pressed");
}
});
But, it will also trigger when I press "5". How can I differentiate between the two?
You can use shiftKey
property in the event
object to check if the SHIFT is pressed when the event occurred.
var keyCode = event.which || event.keyCode;
if (event.shiftKey && keyCode === 53) {
// Shift key is pressed
console.log('% pressed');
}
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