I have a webpage having an input field of type text. The input text is kept hidden. I have to get the value through barcode scanner in the input field. Whenever I need to get input through scanner, I need to set focus on input field and if I set the focus on input, virtual keyboard on mobile browser appears.
$(document).ready(function() {
$('#partsIdScan').on('input', function() {
$('#result').html('$(#partsIdScan').val();
$('#partsIdScan').val('');
});
});
//To set focus on input
$(document).on('click', function(e) {
e.preventDefault();
if (e.target.id != 'parstIdScan') {
$('#partsIdScan').focus();
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id='partsIdScan' type='text' , name='partsIdScan' , autofocus />
<h3 id='result'></h3>
Is it possible to set focus always on input field without opening the virtual keyboard on mobile browser?