Handling input in the action loop