The function is continuous at $x = \frac{\pi}{2}$
$\therefore \lim_{x \to \frac{\pi}{2}} f(x) = f \frac{\pi}{2} $
$\implies \begin{equation} \lim_{x \to \frac{\pi}{2}} \frac{k \cos x}{\pi - 2x} = 3 \end{equation}$
$\implies k \lim_{x \to \frac {\pi}{2}} \frac{\sin( \frac{\pi}{2}-x)}{2 (\frac{\pi}{2} - x)} = 3$
$\begin{align*}\implies \frac {k}{2} \times -1 &= 3 \\ \therefore k & =6 \end {align*}$