XPSetKeyboardFocus

WIDGET_API XPWidgetID XPSetKeyboardFocus(
                         XPWidgetID           inWidget);

Controls which widget will receive keystrokes. Pass the widget ID of the widget to get the keys. Note that if the widget does not care about keystrokes, they will go to the parent widget, and if no widget cares about them, they go to X-Plane.

If you set the keyboard focus to widget ID 0, X-Plane gets keyboard focus.

This routine returns the widget ID that ended up with keyboard focus, or 0 for X-Plane.

Keyboard focus is not changed if the new widget will not accept it. For setting to X-Plane, keyboard focus is always accepted.