(building a real sized trim wheel in hopes of solving the “I’m riding a porpoise across the ocean” problem with trim when flying by hand).
You may have to figure out how long to press the joystick buttons - I found that keeping it high for ~20ms works good for the trim wheel. Just find the function you want to map then tell the sim->options->Arduino Joystick to “start scanning” and then fire off whatever triggers that button / function in your Arduino code and the sim learns it just like a real joystick. You can then map those buttons / functions to just about anything in the sim. You have 32 buttons you can work with in addition to other joystick functions. The sim detects the Arduino as a new and separate joystick device. What I found that works amazingly well is the Arduino joystick library.
When a keyboard.begin() is called it seems to take away control from the real keyboard and there’s all kinds of wacky timing issues to deal with. I found working with keyboard.h to be a bit of a problem.