It might be easier to test for the allowed characters in one of the key events - keydown, keypress, etc.