barcode-hid-reader

1.0.1 • Public • Published

barcode_hid_reader

simple js lib for capturing events from HID barcode scanners

installing via npm:

npm i barcode-hid-reader

import

if using bundler:

import barcode from "barcode-hid-reader";

start capturing:

function onBarcode(barcode) {
  console.log(barcode);
},

// all options are optional, below is default values:
let options = {
    timeout: 30, // timeout between symbols in ms, increase if scanning is unstable
    prefix: "", // barcode prefix
    suffix: "Enter", // barcode suffix
    callback: dispatchEvent, // callback. default is dispatchig custom "barcode" event
    log: false // boolean or callback. if true log into console, if funcion call function with arguments: state, event, event.custom
};

barcode.startCapturing(document, {
  callback: onBarcode,
  ...options
});

stop capturing

barcode.stopCapturing();

Copyright 2019 Anton Grachev

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i barcode-hid-reader

    Weekly Downloads

    41

    Version

    1.0.1

    License

    Apache-2.0

    Unpacked Size

    18.6 kB

    Total Files

    7

    Last publish

    Collaborators

    • fragster.a.n