It's not free, but not expensive either: I have been using Synergy for years for exactly the same purpose. It now costs $19 for the basic version, which is probably what you want. The Pro version for $49 will get you also clipboard sharing (and a lot of other things which are still in development), but for the basic keyboard/mouse sharing the cheapest version should be fine. I believe they have a money-back guarantee too. If you really want to squeeze out the last penny, the source code for the core component is available on GitHub. You will have to compile the C++ code yourself and check out the docs and code to find out how to configure it. I would probably go with the 1.8.8 version in that case.
- Kris