I can help you with this!
In netscape, it is evt.which. In IE, it's event.keyCode. Here's a snippet
of code I use:
function onlyNumbersXB(obj, e, mask) {
var keyCode;
var returnVal = false;
if (window.event) {
e = window.event;
keyCode = e.keyCode;
} else {
// a key, such as delete, was pressed; let it pass through
if (e.keyCode == e.which) keyCode = null;
// else if not a char we don't know what this is; let it pass through
else if (e.charCode != e.which) keyCode = void 0;
// else a char - set it
else keyCode = e.which;
}
// do whatever you want based on keyCode...
// now for the return
if (window.event) {
e.returnValue = returnVal;
return returnVal; // not really necessary but I'm trying to get
Safari to work
} else
return returnVal;
}
}
This method is invoked on a text field, onKeyPress='return
onlyNumbersXB(this, event, mask)'
My problem, as posted elsewhere, is getting Safari to behave itself. It has
window.event and behaves that way. It sets e.returnValue appropriately. It
still doesn't recognize "false" and let's the key pass.
Anyone?
Julia
"Ron Brooks" <ro*******@dendress.com> wrote in message
news:25**************************@posting.google.c om...
Is there any way in JavaScript to determine which key has been pressed
during any of the key-press, key-down, key-up events in IE6+? It
appears the "which" property only works for Netscape.