On May 23, 11:35 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
On May 21, 10:43 am, Ciaran <cronok...@hotmail.comwrote:
Hi has anyone got a function that can detect a user pressing a key
that works cross browser?
I just want to redirect my visitor if they hit escape
try:
document.body.onkeypress=
function(e){
if((e||event).keyCode==27)
location.href="http://google.com";
}
untested
Thanks for the reply! .... but it doesnt seem to be working. I have
this function working in IE but FF is ignoring it ...
if (document.layers) { document.captureEvents(Event.KEYPRESS); }
document.onkeypress = getKey;
function getKey(keyStroke) {
var keyCode = (document.layers) ? keyStroke.which : event.keyCode;
if(keyCode==27) location.href='quit.html';
}