How to (in a vst3 plugin) produce midi messages on a midiKeyboardComponent that can be passed on to a "next-in-line" plugin?

I’m a newcomer to both JUCE and C++ and have tried to solve this issue by reading the topics but I can’t get it right. I hope someone can help me with this issue.

I’ve made a vst3 plugin with a midiKeyboardComponent in it.
The plugin is loaded into a track in my DAW (Reaper) as a so to speak “first-in-line” plugin.
“second-in-line” on the same track is an instrument plugin producing audible sound from the midi messages it receives.
Midi messages that are fed to this lineup from external sources, e.g. my physical midi keyboard works/sounds fine and the midiKeyboardComponent also colours the keys that are played.

I can’t figure out how to (e.g. by mouse clicks) produce midi messages from inside the midiKeyboardComponent that can be passed onto my “next-in-line” audible instrument plugin and have that to sound (!).

I’ve seen that in “SuperVirtualKeyboard” by vsicurella ( it is possible but the code in there is far to extensive and complex for me to understand.

When you call MidiKeyboardState state.processNextMidiBuffer (midi, 0, buffer.getNumSamples(), true) make sure to set “injectIndirectEvents” to true, which refers to the events from the MidiKeyboardComponent.

But you are at the mercy of the host, if they are passed on through the chain. Some may, some might not.

Thank you daniel, I’ll try it.