Reading keyboard in the loop