Yes, you can find this in Engelking's General Topology as Theorem 3.1.16 (for Hausdorff spaces but it works in general).
See also Compactness and product spaces, Coll. Math., 7 (1959), 19--22 by S. Mrowka.
See Problem 3.12.1 in Engelking's book for the following: if $X$ is not compact then there is a sequence $\langle F_\alpha:\alpha<\kappa\rangle$ of nonempty closed sets that is decreasing ($\alpha<\beta$ imlies $F_\alpha\supseteq F_\beta$) and has an empty intersection. In addition we assume that when $\alpha$ is a limit then $F_\alpha=\bigcap_{\beta<\alpha}F_\beta$. Then $\{\langle\alpha,x\rangle:x\in F_\alpha\}$ is a closed subset of $(\kappa+1)\times X$ (where $\kappa+1$ has the order topology and so is compact), whose projection along $X$ is the set $\kappa$ and hance not closed.