barcode scanner in JavaScript? Or plugin/extension

别说谁变了你拦得住时间么 提交于 2019-12-09 11:12:15

问题


I'm looking at writing a USB barcode scanner interface to a web application (offline app). By this I mean that the scanner will be on the client machine not server. So I was wondering what the best design would be.

I know I could write an ActiveX object or native plugin into some browser but this is not ideal, does anyone know if chrome extensions (in javascript) or firefox jetpack would support this kind of functionality.

Any ideas? I would appreciate any leads to follow.

Thanks All

Guido


回答1:


USB barcode scanners implement a HID device (the sane ones anyway), which means they act like an ordinary keyboard. The default mode of operation is to "type" out the barcode, followed by an "Enter". Some barcode scanners are highly configurable, often through scanning configuration barcodes from a chart, allowing you to change this behavior.

The only gotcha is special characters - this depends on what you are scanning.

The good news is that there is no need to write any special controls or extensions or plugins. All you need to do is auto focus on the input control and accept the form based on the enter key being pressed.



来源:https://stackoverflow.com/questions/3262126/barcode-scanner-in-javascript-or-plugin-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!