[removed] How to read a hand held barcode scanner best?

后端 未结 9 1771
温柔的废话
温柔的废话 2020-12-02 08:38

I\'d like to be able to scan barcodes via a hand held scanner and handle the results with Javascript.

A barcode-scanner works almost like a keyboard. It outputs the

9条回答
  •  心在旅途
    2020-12-02 09:10

    I've just started working on a plugin that handles barcode scanning and credit card scanning (built on jQuery):

    https://github.com/ericuldall/jquery-pos

    Simple implementation:

    $(function(){
        $(document).pos();
        $(document).on('scan.pos.barcode', function(event){
            var barcode = event.code;
            //handle your code here....
        });
    });
    

    So far this plugin is only tested with one type of scanner and codes containing only digits, but if you have further requirements that aren't working with it, I'd be happy to adapt it to your needs. Please check out the github page and give it a whirl. Contributions are encouraged.

    E

提交回复
热议问题