Question: I have an HTML input

```
<input type="text" id="txtInput">

```

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.

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

Is there's any way for doing this?

Answer: 
```
<script>    
setTimeout('timedRefresh()', 300000);   
setTimeout('refocus()', 1000);      
//********** KEYPRESS PREVENTION
$(document).ready(function(){
    $("#txtInput").keypress(function() {
        setTimeout('refocus()', 700)
    });
}); 

//********** PASTE PREVENTION $(document).ready(function(){
$(document).on("cut copy paste","#txtInput",function(e) {
    e.preventDefault();
    });  
}); 

```

When you press it clears every character. but you can use barcode scanner to key in your text. You are not allowed to paste also. 700ms timeout is what i believe the most optimized time for barcode to keyin the text and press enter.
```
<input type="number" id="txtInput">

```

That will enable only numbers to be inputed