added key input and collision detection