A KVM switch is a hardware device that allows a user to control multiple computers from a single keyboard, video monitor and mouse. Although multiple computers are connected to the KVM, typically a smaller number of computers can be controlled at any given time. Modern devices have also added the ability to share USB devices and speakers with multiple computers. Some KVM switches can also function in reverse – that is, a single PC can be connected to multiple monitors, keyboards, and mice.
Use
A user connects a monitor, keyboard, and mouse to the console port on the KVM device and the computers to the other can offer different methods of connecting to the computers. Depending on the port density and the type of connection, the KVM may present native connectors on the device where standard cables connect. Another method is a single DB25 or similar connector per port that connects to a special cable which has the video, keyboard and mouse connectors at the computer end. The advantage of the special cable approach is a reduction in the number of cables at the KVM. The disadvantage is the cost of these cables.
Control is switched from one computer to another by the use of a switch or buttons on the KVM device, with the KVM passing the signals between the computers and the keyboard, mouse and monitor depending on which computer is currently selected. Most electronic KVMs allow control to be switched through keyboard commands (such as hitting a certain key, often Scroll Lock, rapidly two or three times) or via an On Screen Display (OSD) menu.
Devices differ in the number of computers that can be connected, with anywhere from two up to 512 computers possible. Enterprise-grade devices can also be daisy-chained to allow even greater numbers of computers to be controlled from a single set of a keyboard, visual display unit and mouse.
A KVM switch is useful where there are multiple computers, but no need for a dedicated keyboard, monitor and mouse for each one. They are frequently used in data centers where multiple servers are placed in a single rack with a single keyboard, monitor and mouse. A KVM switch then allows data center personnel to connect to any server in the rack. A common example of home use is to enable the use of the full-size keyboard, mouse and monitor of the home PC with a portable device such as a laptop, tablet PC or PDA or a computer using a different operating system.
A USB KVM is a device that expands a single USB port into several so that there are more ports available to connect devices to a host system.
USB hubs are often built into equipment such as computers, keyboards, monitors, or printers. When such a device has many USB ports they all usually stem from one or two internal USB hubs rather than each port having independent USB circuitry.Laptop computers may be equipped with many USB ports, but an external USB KVM can consolidate several everyday devices (like a mouse and a printer) into a single hub to enable one-step attachment and removal of all the devices.
Protocol
Each KVM has exactly one upstream port and a number of downstream ports. The upstream port connects the hub (directly or through other hubs) to the host. Other hubs or devices can be attached to the downstream ports. During normal transmission, hubs are essentially transparent: data received from its upstream port is broadcast to all devices attached to its downstream ports; data received from a downstream port is generally forwarded to the upstream port only. This way, what is sent by the host is received by all hubs and devices, and what sent by a device is received by the host but not by the other devices (an exception is resume signaling).
USB KVM’s are not transparent when dealing with changes in the status of downstream ports, such as insertion or removal of devices. In particular, if a downstream port of a hub changes status, this change is dealt with in an interaction between the host and this hub; the hubs between them act as transparent in this case.
To this aim, each KVM switch has a single interrupt endpoint “1 IN” used to signal changes in the status of the downstream ports. When someone plugs in a device, the hub detects voltage on either D+ or D- and signals the insertion to the host via this interrupt endpoint. When the host polls this interrupt endpoint, it learns that the new device is present. It then instructs the hub (via the default control pipe) to reset the port where the new device was plugged in. This reset makes the new device assume address 0, and the host can then interact with it directly; this interaction will result in the host assigning a new (non-zero) address to the device.

By Gani