Input from wireless/wired keyboard

I’m attempting to receive input such as barcode scans from Bluetooth accessories on iOS and wired keyboards for Android. They are sent as plain text and I need to capture them.

Is there any functionality available for keyboard listeners or a method to capture the input?