Callbacks on a Keyboard In DAT are not called, even if the perform window has keyboard focus.
This seems to be quite a major bug. I am delivering a permanent museum installation that receives keyboard messages from hardware buttons and there is currently no way for Touchdesigner to respond to them in perform mode (without someone pressing esc to go back to the editor then f1 to go back to perform mode, at which point the keyboard callbacks work). The app needs to run on startup unmanned so hopefully someone can help me recitify this issue quickly or help find a workaround.
Could it be another app instead of TD has taken focus on your machine, which is why key presses are not seen by TD, and when you manually close/open perform mode TD gets focus again, which is why it then starts to work?
Your simple toe works fine. I’ve matched the perform mode settings to mine and it still seems ok. I’ve been testing this for a few hours now and I can only describe the performance of my app as inconsistent. Sometimes the app will get keyboard focus on start, other times it wont. The app is loading a large video file and has several geometry generation scripts also required on startup (unless these are already baked into the .toe file).
You might be correct something is happening in your loading to steal focus, and onStart() is activated too early for this perhaps.
You could try setting the Panels parameter in the Keyboard In DAT so it only looks at the panel you are viewing through /perform.
To test the theory that setForeground is happening too early, you could throw a button in your window to run that script and see if it works, then at least we can be sure it’s that.