I don't mean to sound like an ass because you CAN do this in software but save yourself the hassle and just buy a hardware multiplexer (www.vetra.com) and some cheap PS/2 cables from monoprice. It will work 100% of the time no matter what and faster than software.

Plus - hardware has no potential of violating the EULA. Software is more of a gray area.