This should work on Due or Zero. They have a native USB port for the USB keyboard and a serial programming port which connects to the computer.
Plug a USB OTG to USB host cable or adaptor into the native USB port. Plug a USB keyboard into the USB host port. Load this example program.
The same thing can be done cheaper using a Trinket M0 and USB to TTL serial cable. The Trinket M0 (not to be confused with the original Trinket) has a SAMD21 microprocessor so it can do many things a Zero can do except only a few pins are exposed.