I tried to use this for a while but it didn't work well when using different VPNs on different computers. So, I bought a commercial device similar to the DIY one here and it works amazingly well. It doesn't require you to log in to the computers first and you can switch by moving across screen edges or with a series of keystrokes. You can also switch the attached USB devices independently of the keyboard and mouse.
The product is sometimes called a boundless, borderless, or roaming KM switch.
The computers need to be able to reach each other, yes. You should be able to do that by adding a route overriding the VPN route (just like how any VPN client has to prevent the traffic to the VPN server from going through the tunnel).
The product is sometimes called a boundless, borderless, or roaming KM switch.
https://www.cdw.com/product/siig-4-port-roaming-km-switch-wi...