Moved keypress and pointer functions