Choopernickel
06-20-2003, 02:50 PM
Morning, all.
I guess it's been, oh, about a week since I started really playing with the keyCodes etc; I've compiled a list of the values returned - which varies by event type - and gotten around most of the keycode duplication because they're not, for the most part, duplicated within the constraints of one event type.
Firebird 0.6, however, infuriates me in that I can't ever know what key was pressed on a keyPress event. There are certain ranges where it's okay, but for example, the charCode 45 is returned for the dash, Insert, numkeyMinus, numkeyMinus+shift, and numkey0+shift. That's far too much crap to have to wade through to guarantee that the dash was pressed. How can I use the keypress event for validation and keep all the possible returned characters from colliding?
Issue the second: using event.preventDefault() on a keydown does not keep the pressed character from entering the text field. try it:
<script type="text/javascript">
function cancel (evt) {
evt.preventDefault();
return false;
}
</script>
<input type="text" onkeydown="cancel(event)"/>
Even when you use onkeydown="return cancel(event)" it doesn't cancel the entry of the key. How can I not only cancel the keydown event, but also the keypress event, if the keydown event attempt does not validate?
The long and short of it is that it doesn't appear to me tobe possible to write keyboard-event-driven validation scripts that work across browsers without using browser sniffers, which I object to for reasons I hardly need to clarify. Is there ANY FREAKING WAY to do this? Somebody please help me out.
Thanks,
ecd.
I guess it's been, oh, about a week since I started really playing with the keyCodes etc; I've compiled a list of the values returned - which varies by event type - and gotten around most of the keycode duplication because they're not, for the most part, duplicated within the constraints of one event type.
Firebird 0.6, however, infuriates me in that I can't ever know what key was pressed on a keyPress event. There are certain ranges where it's okay, but for example, the charCode 45 is returned for the dash, Insert, numkeyMinus, numkeyMinus+shift, and numkey0+shift. That's far too much crap to have to wade through to guarantee that the dash was pressed. How can I use the keypress event for validation and keep all the possible returned characters from colliding?
Issue the second: using event.preventDefault() on a keydown does not keep the pressed character from entering the text field. try it:
<script type="text/javascript">
function cancel (evt) {
evt.preventDefault();
return false;
}
</script>
<input type="text" onkeydown="cancel(event)"/>
Even when you use onkeydown="return cancel(event)" it doesn't cancel the entry of the key. How can I not only cancel the keydown event, but also the keypress event, if the keydown event attempt does not validate?
The long and short of it is that it doesn't appear to me tobe possible to write keyboard-event-driven validation scripts that work across browsers without using browser sniffers, which I object to for reasons I hardly need to clarify. Is there ANY FREAKING WAY to do this? Somebody please help me out.
Thanks,
ecd.