{"id":26119426,"url":"https://github.com/markjaniczak/symbology-scanner","last_synced_at":"2026-03-03T08:41:33.430Z","repository":{"id":186011389,"uuid":"674460140","full_name":"markjaniczak/symbology-scanner","owner":"markjaniczak","description":"A javascript browser module for detecting symbology (i.e. barcodes) scanner hardware input.","archived":false,"fork":false,"pushed_at":"2024-08-20T06:55:36.000Z","size":155,"stargazers_count":25,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-24T19:08:58.264Z","etag":null,"topics":["barcode","javascript","npm","react","scanner","symbology","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markjaniczak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-04T02:25:34.000Z","updated_at":"2025-10-01T06:59:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"4ed59568-7a04-4e04-9104-1ea6fcf51347","html_url":"https://github.com/markjaniczak/symbology-scanner","commit_stats":null,"previous_names":["markjaniczak/symbology-scanner"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/markjaniczak/symbology-scanner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markjaniczak%2Fsymbology-scanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markjaniczak%2Fsymbology-scanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markjaniczak%2Fsymbology-scanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markjaniczak%2Fsymbology-scanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markjaniczak","download_url":"https://codeload.github.com/markjaniczak/symbology-scanner/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markjaniczak%2Fsymbology-scanner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30038535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T06:58:30.252Z","status":"ssl_error","status_checked_at":"2026-03-03T06:58:15.329Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["barcode","javascript","npm","react","scanner","symbology","typescript"],"created_at":"2025-03-10T12:54:52.013Z","updated_at":"2026-03-03T08:41:33.400Z","avatar_url":"https://github.com/markjaniczak.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @use-symbology-scanner\n\n## Table of contents\n- [Table of contents](#table-of-contents)\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Options](#options)\n- [Symbologies](#symbologies)\n    - [Standard Symbologies](#standard-symbologies)\n    - [Custom Symbologies](#custom-symbologies)\n- [Supported hardware](#supported-hardware)\n- [Contributing](#contributing)\n    - [Development](#development)\n    - [Testing](#testing)\n    - [Releasing](#releasing)\n- [License](#license)\n\n## Introduction\n\nThis package provides a simple way to listen for scanner input in the browser. It works by listening for `keydown` events and matching the input against a set of [symbologies](#symbologies).\n\n## Installation\n\nThis package comes in two flavours; `react` and `vanilla`. The `react` package is a wrapper around the `vanilla` package that provides a React hook for listening to scanner input.\n\n### Vanilla\n```bash\nnpm install @use-symbology-scanner/vanilla\nyarn add @use-symbology-scanner/vanilla\npnpm add @use-symbology-scanner/vanilla\n```\n\n### React\n```bash\nnpm install @use-symbology-scanner/react\nyarn add @use-symbology-scanner/react\npnpm add @use-symbology-scanner/react\n```\n\n## Usage\n\n\u003cdetails\u003e\n\u003csummary\u003eReact\u003c/summary\u003e\n\n```jsx\nimport { useSymbologyScanner } from '@use-symbology-scanner/react';\n\nexport const App = () =\u003e {\n    const ref = useRef(null)\n\n    const handleSymbol = (symbol, matchedSymbologies) =\u003e {\n        console.log(`Scanned ${symbol}`)\n    }\n\n    useSymbologyScanner(handleSymbol, { target: ref })\n\n    return (\n        \u003cdiv ref={ref}\u003e\n        \u003c/div\u003e\n    )\n}\n```\n\n\u003c/details\u003e\n\n\u003cbr/\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eVanilla\u003c/summary\u003e\n\n```html\n\u003c!-- index.html --\u003e\n\u003cdiv id=\"el\"\u003e\u003c/div\u003e\n```\n\n```js\n// script.js\nconst el = document.getElementById('id')\n\nconst handleSymbol = (symbol, matchedSymbologies) =\u003e {\n    console.log(`Scanned ${symbol}`)\n}\n\nconst scanner = new SymbologyScanner(handleSymbol, {}, el)\n\nscanner.destroy() // clean up listeners\n```\n\n\u003c/details\u003e\n\n## Options\n\n| Property | Type | Description | Default Value |\n| --- | --- | --- | --- |\n| target | EventTarget | DOM element to listen for keydown events in. | `window.document` |\n| symbologies | Array\u003c[Symbology](#symbology), StandardSymbologyKey\u003e | Symbologies to match against. | [`STANDARD_SYMBOLOGIES`]((#standard-symbologies)) |\n| enabled | boolean | Whether or not the scanner is enabled. | `true` |\n| eventOptions | object | Options to pass to the `addEventListener` call. | `{ capture: false, passive: true }` |\n| preventDefault | boolean | Whether or not to call `preventDefault` on the event. | `false` |\n| ignoreRepeats | boolean | Whether or not to ignore repeated keydown events. | `true` |\n| scannerOptions | object | Options that describe the behaviour of the hardware scanner. | `{ prefix: '', suffix: '', maxDelay: 20 }` |\n\n## Symbologies\n\nA Symbology is a defined method of representing numeric or alphabetic digits using bars and spaces that are easily scanned by computer systems. By default, all of the standard symbologies in the [table below](#standard-symbologies) are matched against the input.\n\n### Standard Symbologies\n\n| Symbology | Allowed Characters | Min Length | Max Length |\n| --- | --- | --- | --- |\n| UPC-A | `0-9` | `12` | `12` |\n| UPC-E | `0-9` | `6` | `6` |\n| EAN-8 | `0-9` | `8` | `8` |\n| EAN 13 | `0-9` | `13` | `13` |\n| Codabar | `0-9`, `-`, `.`, `$`, `:`, `/`, `+` | `4` | |\n| Code 11 | `0-9`, `-` | `4` | |\n| Code 39 | `0-9`, `A-Z`, ` `, `$`, `%`, `*`, `+`, `-`, `.`, `/` | `1` | |\n| Code 93 | `0-9`, `A-Z`, ` `, `$`, `%`, `+`, `-`, `.` | `1` | |\n| Code 128 | `0-9`, `A-Z`, ` `, `$`, `%`, `*`, `+`, `-`, `.`, `/` | `1` | |\n| Code 25 Interleaved | `0-9` | `1` | |\n| Code 25 Industrial | `0-9` | `1` | |\n| MSI Code | `0-9` | `1` | |\n| QR Code | `0-9`, `A-Z`, ` `, `$`, `%`, `*`, `+`, `-`, `.`, `/`, `:` | `1` | |\n| PDF417 | `0-9`, `A-Z`, ` `, `$`, `%`, `*`, `+`, `-`, `.`, `/`, `:` | `1` | |\n| Data Matrix | `0-9`, `A-Z`, ` `, `$`, `%`, `*`, `+`, `-`, `.`, `/`, `:` | `1` | |\n| Aztec | `0-9`, `A-Z`, ` `, `$`, `%`, `*`, `+`, `-`, `.`, `/`, `:` | `1` | |\n| Dot Code | `0-9`, `A-Z`, ` `, `$`, `%`, `*`, `+`, `-`, `.`, `/`, `:` | `1` | |\n\nIn order to only match against a subset of the standard symbologies, you can pass in an array of symbologies to the `symbologies` option:\n\n```jsx\nimport { STANDARD_SYMBOLOGY_KEYS } from '@use-symbology-scanner/core';\n\nconst symbologies = [\n    STANDARD_SYMBOLOGY_KEYS['EAN-8'],\n    STANDARD_SYMBOLOGY_KEYS['EAN-13'],\n]\n```\n\nMissing a common symbology or an issue with one of the standard symbologies? Feel free to open an issue or a pull request. Alternatively, you can define your own custom symbologies.\n\n### Custom Symbologies\n\nYou can also define your own custom symbologies to match against the input.\n\n| Property | Type | Description |\n| --- | --- | --- |\n| name | string | Name of the symbology. |\n| allowedCharacters | RegExp | Allowed characters in the symbology. |\n| minLength | number | Minimum length of the symbology. |\n| maxLength | number | Maximum length of the symbology. |\n\n`allowedCharacters` must only contain a character class. For example, `[0-9]` is valid, but `0-9` is not. You can define a custom symbology like so:\n\n```js\nimport { Symbology } from '@use-symbology-scanner/core';\n\nconst customSymbology = new Symbology({\n    name: 'Custom Symbology',\n    allowedCharacters: '[0-9]',\n    minLength: 1,\n    maxLength: 10\n})\n```\n\n## Supported hardware\nThis library has not yet been tested on any hardware. If you have a scanner that you would like to test this library with, please open an issue or a pull request. Generally, this library *should* work with any hardware that emits keydown events. You can tweak the `scannerOptions` to match the behaviour of your hardware. For example, if your scanner emits a newline character after each scan, you can configure the `scannerOptions` like so:\n\n```js\nconst scannerOptions = {\n    prefix: '',\n    suffix: '\\n',\n    maxDelay: 20\n}\n```\n\nBluetooth scanners may require a longer `maxDelay` value due to latency. If you are using a bluetooth scanner, try increasing the `maxDelay` value to `100` or `200`.\n\n## Contributing\n\n### Development\n\n```bash\ngit clone\ncd @use-symbology-scanner/core\nyarn install\nyarn build\n```\n\n### Testing\n\n```bash\nyarn test\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkjaniczak%2Fsymbology-scanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkjaniczak%2Fsymbology-scanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkjaniczak%2Fsymbology-scanner/lists"}