Why are the keys keyup () and keydown () not played together?

I cannot get jQuery events keyupand keydownwork together. See This jsFiddle: http://jsfiddle.net/CXkam/1/

The code is also for convenience:

$(document).keyup(function (event) {
    alert('Keyup');
});
$(document).keypress(function(e) {
    alert('Keypress: ' + String.fromCharCode(e.which));
});
$(document).keydown(function(e) {
    alert('Keydown: ' + String.fromCharCode(e.which));
});

If you comment on the handlers keypress()and keydown()then the warning is triggered keyup().

But if you do not, then it keyup()never works.

Why not?

Thank!

+3
source share
2 answers

.keyup .keypress , , , , , , . , , "", ( T!), , , T. .keyup .

.keydown .keypress - - .keyup .

+6

hmm, , alert(). , - . , console.log, , .

http://jsfiddle.net/WJsV6/ FF. 3

+5

Source: https://habr.com/ru/post/1793811/


All Articles