Page 1 of 1

Cross browser cancel keystrokes

Posted: Sun Dec 04, 2005 3:31 pm
by alex.barylski
The below code doesn't work AT all in Firefox and I haven't even tried in IE

Anyone know if this is possible to cancel a keystroke in firefox???

I can't decide if I hate firefox more or just dealing with javascript in general :?

Code: Select all

<input type="text" onkeydown="return cancel_key()" />

function cancel_key(e)
{
  var keyCode = (document.all) ? event.keyCode : e.which;
  if(keyCode == 32)
    return false;
  else
    return truel;
}

Posted: Sun Dec 04, 2005 4:02 pm
by Ambush Commander
Well, there is a syntax error in your js. truel.

Posted: Sun Dec 04, 2005 4:17 pm
by foobar
Brainjar has a great tutorial on JS events. Worth checking out.

Posted: Thu Dec 08, 2005 9:57 pm
by Ambush Commander
Well... did it work out?