Implement input handling as a command pattern