简体   繁体   English

JavaScript中的条码扫描器? 或插件/扩展

[英]barcode scanner in JavaScript? Or plugin/extension

I'm looking at writing a USB barcode scanner interface to a web application (offline app). 我正在考虑将USB条形码扫描仪接口写入Web应用程序(离线应用程序)。 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. 我知道我可以在某些浏览器中编写ActiveX对象或本机插件,但这并不理想,有没有人知道Chrome扩展(在javascript中)或firefox jetpack是否支持这种功能。

Any ideas? 有任何想法吗? I would appreciate any leads to follow. 我将不胜感激。

Thanks All 谢谢大家

Guido 圭多

USB barcode scanners implement a HID device (the sane ones anyway), which means they act like an ordinary keyboard. USB条形码扫描仪实现了一个HID设备(无论如何都是理智的设备),这意味着它们就像一个普通的键盘。 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. 您需要做的就是自动对焦输入控件并根据按下的回车键接受表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM