Add keyboard input and loop control