refinement: move code into input manager.