As other answers have explained, USB requires bi-directional communication as part of the way that it works. PS/2, while allowing bi-directional communication, doesn't require it in order to send keys to the computer, but does require it to set the keyboard LEDs.
Theoretically, you could build a device to duplicate the PS/2 signal and send it to a second computer, and discard any commands from the computers, so you'd be able to send your keypresses to multiple computers but the keyboard LEDs wouldn't respond to the num lock, caps lock, and scroll lock states (or any other change of LED state, for example in Linux the keyboard LEDs are sometimes used for alternative purposes).
I'm not sure how complex such a project would be. It's been a while since I worked with PS/2, so I don't know if you could simply bridge a couple of wires/connectors or if you would need an active device (e.g. microcontroller) to pass commands in one direction but discard them in the other. If you did have a microcontroller, you could even make the device such that it can interpret the keyboard LED commands and "combine" them for display (e.g. long flash the LED if it is on on computer one but off on computer two, short flash the LED if it is on on computer two but off on computer one, LED steady on if it is on on both computers, and LED off if it is off on both computers). That would be more advanced though.
Also, if your goal is to be able to control one computer from another computer, or two computers from the same desk, or whatever, you might want to look into:
- VNC (allows controlling one computer from another over a network)
- RDP (also allows controlling one computer from another over a network, built into Microsoft Windows but requires the Professional version)
- KVM (a piece of hardware that lets you switch one set of peripherals between two computers)
40e.g. it may receive status of lock keys. Many keyboards has leds indicating status of lock keys. Try to switch on caps lock, then replace your keyboard, likely the state will still be locked, this information need to come from the pc. – Máté Juhász – 2017-03-06T15:34:28.880
8even PS/2 keyboards receive signals from the PC, otherwise how can it turn on/off the LEDs? – phuclv – 2017-03-06T16:30:18.180
http://www.jonwear.com/morsecode – Joshua – 2017-03-06T20:44:36.457
1@LưuVĩnhPhúc I don't doubt that what you say is true, but a keyboard could easily be made that keeps track of the status of caps lock, num lock, etc on its own for exactly this purpose. Like any device, a keyboard has no obligation to handle incoming signals the way they're meant to be handled, even though it might be tricky to still function to the user's expectation. – Devsman – 2017-03-06T20:56:28.757
8@Devsman you can't do that, otherwise the lock state will be out of sync because it can be changed by software. For example if you plug 2 keyboards and press numlock on this, the LED on the other would toggle. The same can be achieved with on screen keyboard – phuclv – 2017-03-07T01:03:36.020
3
Toggling the LEDs http://codegolf.stackexchange.com/questions/110974/blink-the-caps-lock
– Dohn Joe – 2017-03-07T13:38:45.167See http://codegolf.stackexchange.com/questions/110974/blink-the-caps-lock this would be impossible if we couldn't send signal to the keyboard from the computer!
– Reuben Mallaby – 2017-03-07T16:05:31.8377A USB device must have bi-directional data, simply due to the requirements of the initial handshaking to enable the particular device class. – Steve – 2017-03-07T20:01:30.100
@Devsman, also software might want to disable any state and LED changes from Caps Lock and others, e.g. if you're running a game that doesn't really need Caps Lock, or if you just happen to want to use that key as a Control key. Linux also famously blinks the keyboard LEDs if the kernel panics. :) – ilkkachu – 2017-03-07T22:03:53.833
@NeMo, while you got your answer for USB (i.e. not that easy), it wouldn't be impossibly hard to implement something that acts like a PS/2 keyboard with a microcontroller (say, Arduino). A passive splice might even work too, but would be quite ugly. – ilkkachu – 2017-03-07T22:16:26.613
1
This is far easier to achieve in software: https://github.com/symless/synergy
– b0fh – 2017-03-07T22:42:34.8071@b0fh, doesn't synergy only share the keyboard in the usual way, like KVM switches, allowing input to any of the computers but only to one at a time? I think the question talked about duplicating the input to both computers simultaneously, which is a different idea. (And arguably a less useful one, but that's not the point.) – ilkkachu – 2017-03-08T09:14:17.120
It is possible to build such a device - you just have to decide what to do with the computer's signals! – user253751 – 2017-03-08T20:50:43.487