Refactored checking for end in keys.

I made the key reaction functions return "moved", and then refactored the position of some code.