handle direction keyboard events, and fixing obstacle detection in process