Refactor a bit and consume the up arrow keypress