martin_narg
04-04-2003, 10:18 AM
I've written this small script which handles onkeypress events for a webpage but i'd like to upgrade it so it is also compatible with Mozilla/Netscape 6. I was hoping that someone might be able to post up how to capture onkeypress events for mozilla.
I actually validate the variable "key" (checking to see if it is a letter of the alphabet, etc) later on in catchKey()
var isNS4 = (document.layers);
document.onkeypress = catchKey
if (isNS4) document.captureEvents(Event.KEYDOWN)
function catchKey(e) {
var keyNum = (isNS4) ? e.which : event.keyCode;
key = String.fromCharCode(keyNum).toLowerCase();
alert(key);
}
Many thanks for your help.
martin_narg
I actually validate the variable "key" (checking to see if it is a letter of the alphabet, etc) later on in catchKey()
var isNS4 = (document.layers);
document.onkeypress = catchKey
if (isNS4) document.captureEvents(Event.KEYDOWN)
function catchKey(e) {
var keyNum = (isNS4) ? e.which : event.keyCode;
key = String.fromCharCode(keyNum).toLowerCase();
alert(key);
}
Many thanks for your help.
martin_narg