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

后端 未结 9 1774
温柔的废话
温柔的废话 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 08:58

    A barcode-scanner works almost like a keyboard.

    It depends on the model. Every one that I've used works exactly like a keyboard (at least as far as the computer is concerned)

    It outputs the scanned/translated (barcode->number) data raw (right?).

    It outputs keycodes.

    $(document).on("scanButtonDown"
    

    You probably want keypress, not scanButtonDown.

    Look at the event object to determine the "key" that was pressed.

    To determine when the entire code has been scanned, you might get an "end of data" key (possibly a space or a return) or you might have to just count how many characters are being input.

提交回复
热议问题