OK, I figured it out (a while ago – I didn't only just now figure it out): I had the USB cable plugged directly in to the Teensy to avoid fiddling with stripping the USB cable and soldering it, but it turns out that the holes where the USB cable wires are soldered don't only go to the female USB plug, but also the TWI pins. The TWI initialisation was never completing when the USB cable was plugged directly into the Teensy, but the keyboard worked as expected once I wired up the USB cable to the PCB.