It's a compound, and often compounds can exist in different people's use, between open (key switch), closed (keyswitch) and hyphenated (key-switch).
Generally compounds start out open or hyphenated (note also, in many people's use it might be open when used as a noun and hyphenated when used as a modifier, so someone who said "protected by a key switch" might say "key-switch protection") and if they're used a lot then more and more people will start using them closed and they'll "become a word".
But they can also co-exist in two forms for a long time, or even three (egg-beater, egg beater and eggbeater have been each going for some time).
So, if more than a handful of people are using a particular form, then it's reasonable to consider it a correct form, but not necessarily the correct form.
Your own question points out that both key switch and keyswitch are in use, and suggests that they're both in enough use that both could be considered correct.
We can try some surveying, though I hasten to add that there are a lot of caveats with this source:
This shows key-switch not being used a lot, and we can imagine that it actually overestimates the number due to what I mentioned above about people hyphenating some open compounds when they are modifiers.
It shows key switch being much more commonly used than keyswitch.
This is also quite likely overestimating keyswitch here because keyswitch is also used for a type of switch that is used to make keyboards. The fact that this sort of keyboard design is less common now and keyswitch has declined toward the end of the 1990s backs this theory up.
It may though also overestimate key switch too, because the combination could occur in wider phrases with different meanings. So we aren't conclusive yet.
So we look through results for both term and see which are more often in use. Again while we find keyswitch and key switch both in use for this sort of term, we find the latter considerably more often than the former (discounting other uses of either). Not a massive survey of the language, but enough to be reasonably confident key switch is definitely getting considerable use here.
And as such we can conclude that key switch is much more often used than keyswitch in this context.
It's enough to give us confidence that key switch is certainly correct. Whether we can conclude that keyswitch is incorrect or also correct but less popular requires both more dependable data than this and a consensus on when an English word can be considered "correct" that we are never going to see.
But we can conclude that unless you really, really just like keyswitch better, it might be a good idea to use key switch but not complain about anyone who uses keyswitch either.