Detect when input box filled by keyboard and when by barcode scanner.

前端 未结 11 2085
星月不相逢
星月不相逢 2020-12-01 00:44

How I can programmatically detect when text input filled by typing on keyboard and when it filled automatically by bar-code scanner?

11条回答
  •  自闭症患者
    2020-12-01 01:44

    you can try following example, using jQuery plugin https://plugins.jquery.com/scannerdetection/

    Its highly configurable, time based scanner detector. It can be used as solution for prefix/postfix based, time based barcode scanner.

    Tutorial for usage and best practices, as well discussed about various Barcode Scanner Models and how to deal with it. http://a.kabachnik.info/jquery-scannerdetection-tutorial.html

    $(window).ready(function(){
    
    	//$("#bCode").scannerDetection();
    
    	console.log('all is well');
    	
    	$(window).scannerDetection();
    	$(window).bind('scannerDetectionComplete',function(e,data){
                console.log('complete '+data.string);
                $("#bCode").val(data.string);
            })
            .bind('scannerDetectionError',function(e,data){
                console.log('detection error '+data.string);
            })
            .bind('scannerDetectionReceive',function(e,data){
                console.log('Recieve');
                console.log(data.evt.which);
            })
    
            //$(window).scannerDetection('success');

提交回复
热议问题