Added validation to keyboard input