You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Library To Detect Keyboard Based Scanners For The Browser
📦 Getting Started
npm i js-scanner-detection
💎 Example Usage
importScannerDetectorfrom'js-scanner-detection'letonComplete=(barcode)=>{// Do stuff with the barcodeconsole.log(barcode)}letoptions={onComplete:onComplete}letscannerDetector=newScannerDetector(options)// To remove the event listener and stop the scannerscannerDetector.stopScanning()
✅ Options
{onComplete: false,// Callback after detection of a successful scanningonError: false,// Callback after detection of a unsuccessful scanningonReceive: false,// Callback after receive a chartimeBeforeScanTest: 100,// Wait duration (ms) after keypress event to check if scanning is finishedavgTimeByChar: 30,// Average time (ms) between 2 chars. Used to do difference between keyboard typing and scanningminLength: 6,// Minimum length for a scanningendChar: [9,13],// Chars to remove and means end of scanningstopPropagation: false,// Stop immediate propagation on keypress eventpreventDefault: false// Prevent default action on keypress event}