Added better validation for keyPress and fixed typo.