Refactor scroll_input

I've refactored scoll_input so that it doesn't repeat so much code.