First, lets get the terms straight so we're both talking about the same thing. A "CPU" is a processor chip soldered to the motherboard in the PC. The proper term is "Desktop" -- indicating the whole PC.
Second, I'm not familiar with the switch in the keyboard. I've seen them on wireless keyboards and they are used to turn off the keyboard when not in use to conserve battery life. One in a wired keyboard does not make sense for that purpose, so it MIGHT be used to power on the PC -- but I don't know. You should try it in both positions to see what happens.
If the Desktop still does not turn on, you have few if any options for getting it working again on your own.
To determine the cause with hardware failures, you have to be able run diagnostics. We have no way of accessing your PC from here, so we can not do that for you. You have to do it yourself. You do this by pressing the Esc key repeatedly when rebooting and then, when the HP Startup Menu appears, selecting Diagnostics (usually F2) and letting it run.
But if it is NOT possible to run diagnostics, or if that does not work, then there is NOTHING more you can do by yourself -- and there is NOTHING we can do.
You will need to have the PC physically examined in a service facility by folks that can run their own diagnostics to determine what is wrong with it. And the problem with that is, while HP does do repair work of some sorts on PCs still under warranty, they generally do NOT do repair work on PCs out of warranty because they are not a general purpose repair facility. You would have to contact them in advance to see (1) if they are willing to work on it, and (2) if they will provide you any kind of repair cost estimate.
Be alert for scammers posting fake support phone numbers and/or email addresses on the community. If you think you have received a fake HP Support message, please report it to us by clicking on "Flag Post".