Disable keyboard with HTML input and allow scanners
<p>I have an HTML input</p>

<pre><code>&lt;input type="text" id="txtInput"&gt;
</code></pre>

<p>and I need to disable all keyboard keys for input, only to allow barcode scanners to get the data of the barcode and fill it with the input.</p>

<p>I tried "readonly" and "disabled" and javaScript keydown, but all those solutions disable everything including barcode scanners too.</p>

<p>Is there's any way for doing this?</p>