I'm not sure if the STM32 is a requirement or just happens to be the hardware you saw and began trying with.
However, there is much easier hardware (than stm32) to use to do this.
If you get an arduino Leonardo you can do this with a few lines of code.
You can pick up three Leonardos for $20USD.
The Leonardo is small and will be seen as an HID device as soon as you connect it to your computer. It uses the ATMega 32u4 which implements HID USB so you don't have to do all that work.
Once you get the Leonardo the code is as simple as this example shows:
https://www.arduino.cc/en/Tutorial/KeyboardSerial
#include "Keyboard.h"
void setup() {
// open the serial port:
Serial.begin(9600);
// initialize control over the keyboard:
Keyboard.begin();
}
void loop() {
// check for incoming serial data:
if (Serial.available() > 0) {
// read incoming serial data:
char inChar = Serial.read();
// Type the next ASCII value from what you received:
// this sends the data to your computer as if a user typed it on a keyboard.
Keyboard.write(inChar + 1);
}
}