Stop cursor from going off screen.