I've got a Raspberry Pi which I want to have sends keystrokes via BT to a connected device.
The pi comes with some BT stack already in place, but when I try to connect
to the device it comes up as an audio device.
On Arduino (not what this is about) here are functions to send a keystroke, on Linux there are APIs fo the various USB device classes. Not sure what there is on linux. I've only played with the cli utility.
For Bluetooth there are a couple of ways HID devices are implemented.
The Linux Bluetooth Stack can implement this selecting different profiles using the D-Bus API documented at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt
A while ago I did an experiment to create a HID keyboard service with Python on a RPi: https://gist.github.com/ukBaz/a47e71e7b87fbc851b27cde7d1c0fcf0