I have the following javascript code...Here I am using onKeyPress=\"someFunction( )\" in the body tag to get the keyCode of the key that is pressed.
Pass event object as an parameter and your code will work in IE as well as firefox. The code example is as follows :
function keypress(event) {
alert(event.keyCode);
var key=event.keyCode;
if(key==112 || key==80)
printDiv();
else if(key==101 || key==69)
window.location="http://google.com";
else if(key==114 || key==82)
window.reset();
}