Capture barcode reader (keyboard-wedge) events from javascript
<p>I am developing a web application that has to be used on Honeywell Dolphin 75e devices running Android 4.4.
The integrated barcode reader can operate in "keyboard wedge" mode, but only when a text field has focus.</p>

<p>With desktop browsers I can use that code to capture barcode reader events :</p>

<pre><code>var BarcodesScanner = {
    barcodeData: '',
    deviceId: '',
    symbology: '',
    timestamp: 0,
    dataLength: 0
};

function onScannerNavigate(barcodeData, deviceId, symbology, timestamp, dataLength){
    BarcodesScanner.barcodeData = barcodeData;
    BarcodesScanner.deviceId = deviceId;
    BarcodesScanner.symbology = symbology;
    BarcodesScanner.timestamp = timestamp;
    BarcodesScanner.dataLength = dataLength;
    $(BarcodesScanner).trigger('scan');
}

BarcodesScanner.tmpTimestamp = 0;
BarcodesScanner.tmpData = '';
$(document).on('keypress', function(e){
    e.stopPropagation();
    var keycode = (e.keyCode ? e.keyCode : e.which);
    if (BarcodesScanner.tmpTimestamp &lt; Date.now() - 500){
        BarcodesScanner.tmpData = '';
        BarcodesScanner.tmpTimestamp = Date.now();
    }
    if (keycode == 13 &amp;&amp; BarcodesScanner.tmpData.length &gt; 0){
        onScannerNavigate(BarcodesScanner.tmpData, 'FAKE_SCANNER', '', BarcodesScanner.tmpTimestamp, BarcodesScanner.tmpData.length);
        BarcodesScanner.tmpTimestamp = 0;
        BarcodesScanner.tmpData = '';
    } else if (e.charCode &amp;&amp; e.charCode &gt; 0) {
        BarcodesScanner.tmpData += String.fromCharCode(e.charCode);
    }
});

$(BarcodesScanner).on('scan', function(e){
    alert();
});
</code></pre>

<p>Unfortunately, it does not work on Android.
Is there an API allowing me to capture these events?
Or another browser that handles this?</p>

<p><s><strong>EDIT:</strong></p>

<p>I was able to intercept the events of the barcode reader using a text field as a buffer.</p>

<p>But in this case I can not use any controls that require the focus in my application. Which is quite a handicap.</p>

<pre><code>BarcodesScanner.tmpInput = $('&lt;input /&gt;', {
    type: 'text',
    style: 'position: fixed; top: 0; right: 0; width: 0; height: 0;'
});
$('body').append(BarcodesScanner.tmpInput);
setInterval(function(){
    BarcodesScanner.tmpInput.focus();
}, 500);
BarcodesScanner.tmpInput.on('input', function(e){
    if (BarcodesScanner.tmpInput.val().length &gt; 0){
        onScannerNavigate(BarcodesScanner.tmpInput.val(), 'FAKE_SCANNER', 'WEDGE', Date.now(), BarcodesScanner.tmpInput.val().length);
        BarcodesScanner.tmpInput.val('')
    }
});
</code></pre>

<p></s></p>