ADDED: key input handling;