For the quadratic equation \( x^2 - 6x + k = 0 \), let the roots be \( p \) and \( q \). For a quadratic equation \( ax^2 + bx + c = 0 \):
- Sum of roots: \( p + q = -\frac{b}{a} = -\frac{-6}{1} = 6 \)
- Product of roots: \( pq = \frac{c}{a} = \frac{k}{1} = k \)
- Given: Difference of roots \( |p - q| = 2 \).
Using the identity for the difference of roots:
\[
|p - q| = \sqrt{(p + q)^2 - 4pq}
\]
Substitute \( p + q = 6 \) and \( pq = k \):
\[
\sqrt{6^2 - 4k} = 2
\]
\[
\sqrt{36 - 4k} = 2
\]
Square both sides:
\[
36 - 4k = 4 \implies 4k = 36 - 4 = 32 \implies k = 8
\]
Thus, the value of \( k \) is:
\[
\boxed{8}
\]