Apple - Best way to share one keyboard and mouse between a Mac & PC?
I have never used it, but you can give Synergy a try. It shares keyboard and mouse on one system with one or more systems using software. It works on macOS, Windows and Linux.
After @Ömer Rıfat Kuldaşlı posted Synergy I also found something called ShareMouse. Not sure which is the best so far.