Using a micro computer as a macro keyboard device?
What you need here is a device that can act as a USB HID-class (human interface device) device.

A Raspberry Pi is not well suited to operate as a USB device. It's possible by way of the kernel's USB gadget support, but it's not ideal.

A better option will be one of the ATmega32U4-based Arduinos, like the Arduino Leonardo or Arduino Micro. The Arduino framework includes Keyboard and Mouse classes specifically for this sort of application.