Skip to content

Instantly share code, notes, and snippets.

@abdo-host
Created January 11, 2022 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdo-host/7a411c22f286420e8bb2621934564a81 to your computer and use it in GitHub Desktop.
Save abdo-host/7a411c22f286420e8bb2621934564a81 to your computer and use it in GitHub Desktop.
jquery-scanner-detection
<p id="pTest"></p>
<input id="iTest"></input>
<div id="some-test-element">Click me</div>
<div class="search">
<input id="foo" type="text" value="y u no work" autofocus/>
</div>
<div id="focus-here">this spot</div>
$(document).scannerDetection({
timeBeforeScanTest: 200, // wait for the next character for upto 200ms
avgTimeByChar: 100, // it's not a barcode if a character takes longer than 100ms
onComplete: function(barcode, qty){
$('#pTest').text(barcode);
alert(barcode);
} // main callback function
});
$('#some-test-element').click(function() {
$('div#focus-here').focus();
})
//$('.search').find('input#foo').focus();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://rawgit.com/kabachello/jQuery-Scanner-Detection/master/jquery.scannerdetection.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment