Added input check and enter key event