If you use a Teensy, the software side is really easy, because Teensyduino includes
a library for this. MechanicalKeyboards SiliconWizard linked to even sells Teensy 2.0s (ATmega32u4) to be used as keyboard controllers. Unlike later Teensies (LC, 3.x) or Arduinos (Pro Micro, Leonardo), there is a "bare-metal"
USB keyboard library for Teensy 2.0 and 2.0++ (also
mouse and
raw HID), so you only need avr-binutils, avr-gcc, avr-libc, the aforementioned library, and
teensy_loader_cli to upload the sources to the Teensy via USB. (The
PS/2 library is designed for use in the Arduino environment, but I think you could adapt it to Teensy 2.0 bare-metal without too much hassle. Note that for PS/2 port, the irq pin must be one of those marked D0, D1, D2, or D3 just below the chip, and the other data pin can be any other I/O pin except D6 in the corner, connected to the LED.)
Arduino Pro Micros also use ATmega32u4, and are essentially clones of the SparkFun Pro Micro with an Arduino Leonardo bootloader (so you need to choose Arduino Leonardo in Arduino development environment). There are plenty of
tutorials,
hackaday work logs, and so on, for implementing a keyboard; just use "pro micro" as the search key. On those, you can use the aforementioned
PS/2 library too, but note that you'll probably want to use pin 7 as the irq pin, and pin 5 for data.
The downside is that you'll need basically all of the I/O pins for a full keyboard matrix;
N input and
M output pins for
N×
M keys. You'll need a diode in series with each key, to avoid "phantom" keys. Because only one of the
M output pins is active at any time, you can use an external mux chip or even a counter and a mux to pull each one of the
M output pins high, using just 2-3 pins on the microcontroller. I personally have a couple of Teensy 2.0++'s, with an Atmega AT90USB1286, which has almost double the I/O pins, lots more flash (130048 bytes) and RAM (8192) and EEPROM (4096 bytes); I'd definitely use one of these for a full-sized keyboard (say, more than 64 keys) rather than an ATmega32u4 one. The same libraries support 2.0++ just as well as 2.0, and the pinout and pin selection is actually much easier (eight interrupt-capable pins, almost all output pins in consecutive order).
Key debouncing is an art in and of itself, and various implementations exist, especially in the Arduino environment. I personally prefer a different debouncer, using a dead-time counter, so that each key changes state immediately, and just has a fixed period afterwards when additional changes are ignored. The counters require a byte per physical button of RAM (including the state bit), but ATmega32u4 has 2560 bytes of RAM, so it is not a problem. (AT90USB1286 has 8192 bytes, so it is even less of a problem there.) I also prefer to use at least a 2 kHz scan rate (each key checked at 0.5 ms intervals), in which case the dead time is adjustable from 0.5ms to 63.5ms, keeping the USB HID latency (hopefully, not measured!) under 2 ms. My Pro Micro Gamepad project I linked to in the other thread, having only ten buttons, does not use a matrix at all, just internal pullups and an input pin per button. I did design a
Teensy LC button matrix board with 32 buttons and 9 potentiometers as an example for use in a DIY arcade cabinet or control console, but I never built it myself; the idea is that you solder wires or connectors and the diode pairs at the same time, but I don't know how fiddly that gets. I just tried to keep the parts count (cost!) down.