Javascript examples for DOM:Key Event
Switch on key code in key down event handler
<html> <head> <script> function preventStuff () {/* w w w .ja v a 2s.c om*/ var e = window.event; if(e.ctrlKey) { switch(e.keyCode) { case 82 : document.body.innerHTML += "<p>Window refresh prevented.</p>"; e.returnValue = false; break; case 72 : document.body.innerHTML += "<p>Browser history prevented.</p>"; e.returnValue = false; break; } } } </script> </head> <body onkeydown="preventStuff()"> </body> </html>