It has been shown by Claire Voisin in 2003 that one cannot always deform a compact K\"ahler manifold into a projective algebraic manifold, thereby answering negatively a question raised by Kodaira. In this article, we prove that under an additional semipositivity or seminegativity condition on the canonical bundle, the answer becomes positive, namely such a compact K\"ahler manifold can be approximated by deformations of projective manifolds.