Synergy works well for this purely in software. Unfortunately it's not free or open source, but it's relatively inexpensive.
[1]: https://github.com/input-leap/input-leap/commit/78ca8f1ef7b6...
There is an open source fork that branches off version 1.9: https://github.com/debauchee/barrier#what-is-it
Way too much BS to get it running though.
Nowadays you have to look at the logs and search through a pile of github issues to find the right solution to make it work, but once it's up it's pretty trouble free.
Only real pain point is clipboard sharing, which works for small clipboards, but, copy too much text and it takes forever to switch.