ASCII value of enter key

How to get the ascii value of enter key using javascript events?

The code is 13 so if for example you want to ignore all enter key presses on your page you could use:

function kH(e) {
var pK = e ? e.which : window.event.keyCode;
return pK != 13;
document.onkeypress = kH;

I tend to use onKeyUp instead of onKeyPress…

document.onkeyup = function(e){     
    var keycode = (e === null) ? window.event.keyCode : e.which;
    if(keycode === 13) {
        alert('You pressed "Enter"');

Doesn’t IE have trouble firing the enter key on the keypress event?

It may be required to use the onkeyup or onkeydown event for the enter key to reliably be detected.