Listen for keyevent on native keyboard

I am raising a keyboard but the intent is to send keys to a remote device, so I’d like to listen for keyevents without having an input text field. Is this possible? If so, how can that be done?