function keyPress(keyPressEvent)
{
    var result = 0; // RETURN ZERO IF TOTAL FAILURE. WE HAVE NO WAY OF REFERENCING THE EVENT
    if( !keyPressEvent ) 
    {
        //if the browser did not pass the event information to the
        //function, we will have to obtain it from the event register
        if( window.event ) 
        {
            //DOM
            keyPressEvent = window.event;
        }
        else 
        {
            return result;
        }
    }
    if( typeof( keyPressEvent.which ) == 'number' ) 
    {
        //NS 4, NS 6+, Mozilla 0.9+, Opera
        result = keyPressEvent.which;
    } 
    else if( typeof( keyPressEvent.keyCode ) == 'number'  ) 
    {
        //IE, NS 6+, Mozilla 0.9+
        result = keyPressEvent.keyCode;
    }
    else if( typeof( keyPressEvent.charCode ) == 'number'  )
    {
        //also NS 6+, Mozilla 0.9+
        result = keyPressEvent.charCode;
    } 
    return result;
}

