5. The line $y=k x-2$ intersects the parabola $y^{2}=8 x$ at points $A, B$. If the x-coordinate of the midpoint of segment $A B$ is 2, then the length of segment $A B$ $|A B|=$ $\qquad$
$$
\left\{\begin{array}{l}
y=k x-2, \\
y^{2}=8 x
\end{array} \Rightarrow k^{2} x^{2}-(4 k+8) x+4=0 \Rightarrow x_{0}=\frac{2 k+4}{k^{2}}=2 \Rightarrow k^{2}=k+2\right.
$$
$\Rightarrow k=2 \Rightarrow x^{2}-4 x+1=0$. So $|A B|=\sqrt{5} \cdot \sqrt{16-4}=2 \sqrt{15}$.