Open-source KVM software
But if you want to take a shortcut, you can use something like Barrier or ShareMouse to share one keyboard/mouse between your PC and iMac, so they both act like one PC (somewhat).
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.
Samsung Odyssey Neo G9 Help for switching between PC and MacBook
1 project | reddit.com/r/ultrawidemasterrace | 1 Jul 2022
Using Linux and Windows as if they were on two different monitors
3 projects | reddit.com/r/linux | 30 Jun 2022
Having trouble opening a port for Barrier
1 project | reddit.com/r/WindowsHelp | 27 Jun 2022
Help building a mac setup on gaming desktop
2 projects | reddit.com/r/macsetups | 27 Jun 2022
Anyone have experience with using Ableton through Teamviewer?
1 project | reddit.com/r/ableton | 22 Jun 2022