To factor $ x^2-kx+4x-4k $ we can use factoring by grouping.
Group $ \color{blue}{ x^2 }$ with $ \color{blue}{ -kx }$ and $ \color{red}{ 4x }$ with $ \color{red}{ -4k }$ then factor each group.
$$ \begin{aligned} x^2-kx+4x-4k &= ( \color{blue}{ x^2-kx } ) + ( \color{red}{ 4x-4k }) = \\ &= \color{blue}{ x( x-k )} + \color{red}{ 4( x-k ) } = \\ &= (x+4)(x-k) \end{aligned} $$