You can of course just put a simple four pole switch and the job is done.
However, you also need to consider what happens when the operating system in the computer which does not have the keyboard connected, detects that and decides that something is very wrong.
By using a KVM switch, each computer sees a keyboard, but data is only sent to the one which you select.
Try the simple switch, if it does what you want, that is good.
But be prepared for problems.
The quick answer to those problems is a KVM switch.
Building a true USB KVM switch is not a trivial task.
JimB