TITLE: When does the generalized Cantor space embed in a $\kappa$-compact space
QUESTION [6 upvotes]: The generalized Cantor space is the space $2^\kappa$, with basic open sets
$$
[\sigma] := \{f\in 2^\kappa : \sigma\subseteq f\},
$$
for $\sigma\in 2^{<\kappa}$.
A space is $\kappa$-compact if every open cover has a subcover of cardinality (strictly) smaller than $\kappa$.
Problem. For which cardinals $\kappa$ does the generalized Cantor space $2^\kappa$ 
embed as a subspace of every $\kappa$-compact set $C\subseteq 2^\kappa$ with $|C|>\kappa$?
It is a classic result that this holds for $\kappa=\omega$. 
In the original formulation of this problem, I mentioned that,
in light of an earlier answer, the case where $\kappa$ is weakly compact
is particularly interesting, and the expected answer is "for all of these".
According to Yair Hayut's answer below, this is wrong. The full problem,
as stated above, remains open (we need cardinals for which the
answer is positive).

REPLY [7 votes]: Let $\kappa$ be an uncountable regular cardinal that is not weakly compact and let $C$ be a $\kappa$-compact subset of ${}^\kappa 2$. Assume, towards a contradiction, that there is a continuous injection of ${}^\kappa 2$ into $C$. Since $C$ is closed in ${}^\kappa\kappa$, Lemma 2.9 of this paper shows that $C$ contains a closed set homeomorphic to ${}^\kappa 2$. By our assumption, $\kappa$ is not weakly compact and a theorem of Hung and Negrepontis (see Corollary 2.3 of the above paper) implies that the spaces ${}^\kappa 2$ and ${}^\kappa\kappa$ are homeomorphic. This is a contradiction, because an easy argument shows that $\kappa$-compact subsets of ${}^\kappa\kappa$ do not contain closed subsets homeomorphic to ${}^\kappa\kappa$ (see Fact 1.5 of the above paper). 
Let $\kappa$ be indestructible supercompact, let $\lambda>\kappa$ be inaccessible and let $G$ be $Col(\kappa,{<}\lambda)$-generic over $V$. 
In this situation, standard arguments (see, for example, Lemma 7.6 of this paper) show that, in $V[G]$, all subtrees of ${}^{{<}\kappa}\kappa$ with more than $\kappa$-many $\kappa$-branches contain a subtree isomorphic to ${}^{{<}\kappa}2$. In particular, in $V[G]$, $\kappa$ is weakly compact and every $\kappa$-compact subset of ${}^\kappa 2$ of cardinality greater than $\kappa$ contains a continuous injective image of ${}^\kappa 2$. 
Let $\kappa$ be a weakly compact cardinal with the property that there is a subset $A\subseteq\kappa$ such that $\kappa^+=(\kappa^+)^{L[A]}$ and the set $\{\alpha\in S^\kappa_\omega \mid cof^{L[A\cap\alpha]}(\alpha)=\omega\}$ is stationary in $\kappa$. In this situation, a modification of a classical argument of Solovay shows that there is a weak $\kappa$-Kurepa tree, i.e. a subtree $T$ of ${}^{{<}\kappa}2$ with $\kappa^+$-many $\kappa$-branches and $\vert T(\alpha)\vert=\vert\alpha\vert$ for stationary many $\alpha<\kappa$. Since $\kappa$ is weakly compact, the tree $T$ contains no $\kappa$-Aronszajn subtrees and a theorem of Juhász and Weiss (see Lemma 2.2 of the first paper) shows that the corresponding closed subset $[T]$ of ${}^\kappa 2$ is $\kappa$-compact. By results of Mekler and Väänänen, there is no continuous embedding of ${}^\kappa 2$ into $[T]$. 
The existence of weak $\kappa$-Kurepa trees at every inaccessible cardinal $\kappa$ is consistent with the existence of very large large cardinals (including supercompact cardinals). This is discussed on page 33 of this paper by S. Friedman, Hyttinen and Kulikov.