Hi

I wrote a Firefox key handler class about 4 years ago and have been using it without problem ever since. A few days ago, I dropped my iPhone on the left side of my laptop keyboard, the screen did this jittery random data dance and the computer rebooted. Ever since, this once reliable class refuses to register keyPress events in Firefox. I've been Googling for a couple of days now, but nothing seems to fix the problem. I tried another key event watcher I found somewhere, years ago, and key presses are registered by that utility, but for some bizarre reason, my custom class doesn't work. Below is the full code for the class. Does anyone have an ides why something that has worked flawlessly for years would suddenly stop working? The Safari, Chrome and Opera versions of the class all still work perfectly.

javascript Code:
 
// #mark -
// #mark Class: NFirefoxKeyObserver
// #mark -
 
function NFirefoxKeyObserver(inNEventManager)
{
	var t			= this;
 
	t.eventManager	= inNEventManager;
	t.modifiers		= {command: false, option: false, shift: false, capsLock: false};
	t.key			= '';
	t.capsLock		= false;
 
	// add event listeners
	// Note: Added console.logs to see when events are fired
	document.onkeydown	= function(inEvent) { console.log('key down: ' + inEvent.keyCode); t.handleKeyDown(inEvent); };
	document.onkeypress	= function(inEvent) { console.log('key press: ' + inEvent.charCode); t.handleKeyPress(inEvent); };
	document.onkeyup	= function(inEvent) { console.log('key up: ' + inEvent.keyCode); t.handleKeyUp(inEvent); };
}
 
 
// #mark -
// #mark Handlers
// #mark -
 
NFirefoxKeyObserver.prototype.handleKeyDown = function(inEvent)
{
	var t			= this;
 
	// normalize key
	switch (inEvent.keyCode)
	{
		case	224:
				t.modifiers.command		= true;
				break;
 
		case	18:
				t.modifiers.option		= true;
				break;
 
		case	16:
				t.modifiers.shift		= true;
				break;
 
		case	20:
				t.modifiers.capsLock	= (t.modifiers.capsLock == true) ? false : true ;
				break;
	}
 
	CancelEvent(inEvent);
}
 
 
NFirefoxKeyObserver.prototype.handleKeyPress = function(inEvent)
{
	//log('handleKeyPress: ' + inEvent.charCode);
 
	var t			= this;
	var keyCode		= inEvent.keyCode ? inEvent.keyCode : 0 ;
	var charCode	= inEvent.charCode ? inEvent.charCode : 0 ;
	var timeStamp	= GetTimeStamp();
	var interval	= (t.lastKeyTime == undefined) ? 0 : timeStamp - t.lastKeyTime;
	var type		= 'character';
	var value		= 0;	
 
	t.lastKeyTime	= timeStamp;
 
	//console.log('handleKeyPress: ' + inEvent.charCode);
 
	if (charCode == 39)
	{
		// apostrophe
		keyCode		= 39;
		value		= String.fromCharCode(keyCode);
	}
	else if (charCode == 32)
	{
		keyCode	= 'space';
		type	= 'edit';
		value	= ' ';
	}
	else if (charCode == 0)
	{
		// one of the special keys (delete, tab, return, etc...)
		var record	= GetKeyRecord(keyCode);
 
		keyCode	= record.code;
		type	= record.type;
	}
	else if (charCode == 90)
	{
		keyCode		= 90;
 
		if (t.modifiers.command && t.modifiers.shift)
			charCode	= 122; // convert Z -> z (undo command)
 
		value		= String.fromCharCode(charCode);
	}
	else if (charCode == 61)
	{
		keyCode		= 61;
 
		if (t.modifiers.command)
			charCode	= 43; // convert = -> + (magnify command)
 
		value		= String.fromCharCode(charCode);
	}
	else
	{
		keyCode	= charCode;
 
		if ((keyCode > 47) && (keyCode < 58))
			type	= 'number';
 
		value		= ((type == 'character') || (type == 'number')) ? String.fromCharCode(keyCode) : 0 ;
	}
 
	CancelEvent(inEvent);
 
	var result		= {	type: type, 
						code: keyCode, 
						value: value, 
						interval: interval,
						modifiers: t.modifiers};
 
	log('keypress result: ' + result.toSource());
 
	//t.eventManager.handleKey();
}
 
 
NFirefoxKeyObserver.prototype.handleKeyUp = function(inEvent)
{
	var t			= this;
 
	switch (inEvent.keyCode)
	{
		case	224:
				t.modifiers.command		= false;
				break;
 
		case	18:
				t.modifiers.option		= false;
				break;
 
		case	16:
				t.modifiers.shift		= false;
				break;
	}
 
	CancelEvent(inEvent);
}