Many CGECreateKeyboardEvent in quick succession causing function and dictation buttons to be pressed?

Hi!

I hope everyone reading is doing well. I am working on developing a reinforcement learning agent that involves sending scan codes to a window, which I've been doing by sending virtual scan codes with CGEventCreateKeyboardEvent per the docs. There is no event source when I send the keyboard events.

However, when many keyboard events are happening (with the keys 'q', 'w', 'e', 'r', 'f', 'd', 's', space, arrow keys) in quick succession (<250ms), the enable dictation popup or the function button emojis popup appear for seemingly no reason. I have verified that I am using the correct scan codes for these keypresses, so I am wondering what else could cause this to happen. It is as if I am choosing to press f5 or fn. It does not happen when 'a' is the only button being pressed in quick succession.

One thing that I have not been able to easily find is the scan code inputs for dictation nor the function button. do these scan codes overlap somehow?

Thank you all for the help! Hunter

One thing that I learned over the past hour or so is that dictation and emojis can pop up using fn + d and fn + e respectfully. But why would the function button be activated?

Many CGECreateKeyboardEvent in quick succession causing function and dictation buttons to be pressed?
 
 
Q