Unfortunately, not all keyboards are equal communicators. As technology has developed, protocols and connectors have continuously changed for better or for worse. Here is information about the most prominent protocols and connectors used at some point by IBM and co keyboards.
The Set 1 (PC/XT) protocol was the original PC scancodes effectively introduced by the IBM Personal Computer (5150) and subsequently used for the IBM Portable Personal Computer (5155) and IBM Personal Computer XT (5160). Modern PCs are largely incompatible with interfacing directly with Set 1/XT keyboards despite raw XT codes still technically supported by legacy BIOS and operating systems.
The Set 3 protocol was introduced with the IBM 3270 PC (a PC-based IBM 3270 terminal emulator), largely remaining unique amongst IBM's terminals for the '80s and '90s. Whilst later PS/2 keyboards should be compliant with Set 3, PCs then and now rarely had native support for this protocol. Even on the 3270 PC, an add-on card and BIOS extension were needed to translate the keyboard's scancodes back into Set 1/XT for the base PC to understand it.
August 1984 (AT), April 1987 (PS/2)
The retroactively-named Set 2 (PC/AT) protocol was initially a subset of Set 3 introduced with the IBM Personal Computer AT (5170). A marked improvement over Set 1/XT, Set 2/AT allows commands to be received by the keyboard, making features like lock-lights possible. Set 2 was later extended into PS/2 with the launch of its namesake family of computers - the IBM Personal System/2. As differences began to appear between IBM's terminals and PCs, Set 2 and Set 3 eventually ended up with different scancodes for new key additions such as Windows keys during the late-'90s.
The Universal Serial Bus (USB) Human Interface Device (HID) class is an industry-standard specification dictating how computer peripherals such as keyboards operate, effectively ending the need for the three IBM Set scancodes. All USB keyboards prescribe to HID and it has supplanted PS/2 in everything except legacy computing and scenarios that require keyboard-based interrupts instead of the host computer polling the keyboard (as what happens with USB communication). Some USB keyboards can support outputting PS/2 scancodes, however, making a simple passive adapter possible.