You need to attach the event to your page as well. You could attach the event at onload of body tag or you could simply run it.
function attachKeyEventToPage() {
if (document.addEventListener) { // anything but IE
// passing event to function as closure
document.addEventListener("keydown", function(e) { convertEnterKey(e) }, false);
}
else { // IE
// passing event to function as closure
document.attachEvent("onkeydown", function(e) { convertEnterKey(e) })
}
}
function convertEnterKey(inEvent) {
var e = inEvent;
var keyCode;
if (!e || (typeof(e)=="undefined")) { e = window.event; }
// may not need parseInt, but I still like to do so :P
keyCode = (e.keyCode) ? parseInt(e.keyCode,10) : parseInt(e.which, 10);
...
}