Search code examples
androidtitaniumappcelerator

Titanium listen for silent input event


I am developing an application that has to listen for input from a hardware QR Code Scanner, and Card Swiper (both HID devices). I want to listen for input and evaluate the input. I was thinking of TextArea input that constantly has focus but I would rather not do that. Is there a simple way any one can think of to have some sort of event listener that is always listening on for input. Also, is there any other way of listening on ports in Android such as /dev/hidraw1...etc? I am able to get the input fine via in a text-area but would be great to listen from a specific device as well.


Solution

  • What I ended up doing was actually creating a hidden input field that always has focus and blurring it on input. Listening to the onReturn event on the input ran a onHidInput function, which blurred the input (lost focus), disabled it and processed the data, than gave focus on result. I was originally doing on change but that did every character input when the scan or swipe happened, So I was able to program the devices so they contained a carriage return after input, which allowed me to listen to the onReturn event and get the entire data to process.