$(document).on('keydown', function(e) {
if (e.shiftKey) {
$('body').append('test1');
}
});
$(document).on('keyup', function(e) {
if (e.shiftKey) {
$('body').append('test');
}
});
keyup never triggers for me but keydown does, why is that?
event.shiftKey
always return false
on keyup.
Check for keyCode === 16
instead (which is the shift key code, on keyup):
$(document).on('keydown', function(e) {
if (e.shiftKey) {
$('body').append('test1');
}
}).on('keyup', function(e) {
if (e.keyCode === 16) {
$('body').append('test');
}
});
Demo: http://jsfiddle.net/maniator/eyX5N/
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