I want to enable a barcode scanner to be used as shortcuts/input on various pages of the system. The barcode scanner acts exactly like a keyboard input.
There will be two parts:
2) A handler which will figure out what to do with the barcode
This project is ONLY for #1 above.
The "keyboard" input when a barcode is scanned is as follows:
- It starts with TWO exclamation points. You can use this to initiate listening for a barcode
- Symbology ID is optional and may be one of: A, E0, FF, F, B1, B2, B3, ]e0
- Barcode can be any length and consist of numbers, letters, spaces
- The end of the barcode is signaled by a newline
How I envision it working:
- A listener will listen on the document for two exclamation marks (!!) in a row.
- If the time between characters inputted is more than a second, it should start over, and (if possible) pass along the inputted input to the page. For example, if I'm in a text input box and type '!!hi' and wait a second, then that text should get inputted there after the timeout.
- If a barcode is read properly, the characters should not be output anywhere on the page.
- I should be able to set a handler function. The handler function gets passed two parameters: 1) the barcode (without !!, symbology id, or newline character). and 2) the symbology id, if present.
- My various handler functions I will write and will do things such as adding a lineitem to an order via ajax, looking up a product, etc. depending on the context in which a barcode is scanned.
This code will be open-sourced when done. Comments in the JS and configurability are welcome.
This library should get you part of the way there: [url removed, login to view]
I do have Prototype loaded on many of the pages this will be used on, so if you feel you must use it, you can.