Use keydown instead of keypress for max length checking.