Must click on window before keyboard input recieived

This should be easy but I dont see it.

I have a simple player ap that uses stop a start commands from a arduino with bluetooth acting as a hid keyboard.

When I start my ap, inputs from the arduino are not seen by the program. I can load the play list(from a file-load) and it still doesnt get input. If I click on the component window, everything works from then on. This is running on a raspberry pi. I want to be able to boot the pi, have it autoload start my program and a default play list, then control it from the arduino without having to click on the window.

I tried using component::tofront(), and component:grabKeyboardFocus() .

What do I need to do to get keyboard routed to the window at startup?

Is there a way to automatically route a mouse click to my program?

I found a reference where Jules answered the reason. (Setting the keyboard focus initially)
I added a timer at startup, grabbed focus in the timer callback and it worked.