In normal cases, go for keyup:
$(document).keyup(function(e){
console.log(e.which);
});
Reasons:
keydownkeeps firing when user holds the keys down, whilekeypressandkeyupfire only once.keypressdoesn’t detect special keys (e.g.SHIFT),keydownandkeyupdo.
