The pawn is four squares away from promoting, so you can make an imaginary 4x4 square with the pawn in the bottom right corner. If the king is in the square, it's in time to stop the pawn. If the king is outside the square, the pawn can promote easily.