Javascript examples for DOM:Key Event
Prevent Browser from refreshing when keypress is handled
<html> <head> <script> function preventStuff () {/*from w ww. j a va 2s.c o m*/ 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>