Barcode Scanner Emulator
Scanner Works in Notepad but Not POS
This is one of the most reported barcode issues, and it almost always means the scanner and connection are fine — the bug is in how your application handles keyboard input.
Problem
Scanning into a plain text editor produces the correct value every time, but scanning into your POS system, web app, or internal tool produces nothing, partial input, or incorrect behavior.
Possible causes
- The target field doesn't have keyboard focus at scan time, or focus is on a non-input element
- A
keydownhandler callspreventDefault()in a way that blocks character entry - The app relies on
pasteorinputevents that scanner keystrokes don't naturally trigger the way you expect - An input mask or validation regex rejects a valid character in the scanned payload
- The ENTER/TAB suffix triggers an unintended action (submitting a form early, closing a modal, navigating away)
- The scan happens faster than a debounced or throttled input handler can register every keystroke
Diagnostic workflow
- Open the Keyboard Event Tester in the same browser and scan the barcode. If every character logs correctly here, the browser and OS are receiving events fine, so the bug is in your app's event handling.
- Check whether your input field is focused right before the scan happens in the real workflow (not just when you manually click it for testing).
- Open your browser's DevTools console and check for JavaScript errors thrown during the scan — a thrown error mid-handler can silently stop processing further keystrokes.
- Temporarily remove any input mask, validation, or debounce logic and re-test to isolate which layer is dropping the input.
- Check whether your app listens for
keypress(deprecated and unreliable for some keys) instead ofkeydown/keyup.
How to fix
- Ensure the target field is programmatically focused whenever the workflow expects a scan (e.g., immediately after adding a line item)
- Replace
keypresslisteners withkeydown/keyup, sincekeypressis deprecated and handles some keys inconsistently - Audit any
preventDefault()calls in keyboard handlers to ensure they don't block legitimate character keys - Loosen input masks/validation to accept the full character range your barcode symbologies can produce, then validate the assembled value instead of individual keystrokes
- Match the scanner's suffix to what your form expects (see ENTER vs TAB Suffixes)