asp.net - 条码扫描仪和键盘问题

标签 asp.net keyboard barcode barcode-scanner

条形码扫描仪和键盘。 注意:我的条形码扫描仪是 USB 类型。 enter image description here

然后... enter image description here

如果我在 auto.aspx 页面,必须使用什么函数来触发键盘? 我尝试了这段代码但没有成功:

var barcode = document.getElementById('barcodenum');
barcode.addEventListener("keypress", function() { alert("Please use Barcode Scanner!"); document.getElementById('barcodenum').value = "";}, true);  

最佳答案

恐怕您无法通过 JavaScript 做到这一点。如果您正在开发桌面应用程序,这是可以完成的。

编辑: JavaScript 中唯一的解决方案是测量按键事件之间的时间。条形码扫描仪比人类更快,因此如果您为两次按键之间的间隙设置(实验发明的)时间限制,您可能会解决这个问题。 (Source 这个想法。)

关于asp.net - 条码扫描仪和键盘问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14606005/

相关文章:

c# - RadListView 控件未指定项目占位符

asp.net - 如何将 CssClass 应用于一系列具有不同 ID 的相似对象

multithreading - 低级键盘 Hook 不在 UI 线程

ios - 条形码扫描仪应用程序

android - 使用 Zbar 或 Zxing 在各个方向扫描条码

c# - 当存在 IntegrationEvents 时,Pub/Sub 模式如何解耦微服务

asp.net - 在 IIS 6/ASP.NET webforms 中记录服务器范围的请求数据(包括 POST 数据)

ios - 如何在 iOS 中退出键盘

ubuntu - 防止 super 键进入 Ubuntu 20 中的搜索栏

android - 嵌入式 ZXing - 我缺少什么?