VUE.JS条形码扫描仪生产“键盘”仅当用户在输入框上时。当用户不在输入框上时要收听什么事件?
我使用手动条形码扫描仪的工作,
我希望有可能在没有输入框的情况下捕获扫描事件,除了我在哪里,并扫描我可以听的代码并执行所需的操作。
我尝试在已安装和创建的功能中使用以下代码,但没有打印控制台。log:
window.addEventListener ('keypress', function (e) {
console.log ('window scanner barcode');
})
document.addEventListener ('keypress', function (e) {
console.log ('document scanner barcode');
})
谢谢
I work with a manual barcode scanner
I want the possibility of capturing the scan event without a input box, except that wherever I am and scan the code I can listen to it and do the required action.
I tried using the following code in the mounted and created functions but did not print the console.log:
window.addEventListener ('keypress', function (e) {
console.log ('window scanner barcode');
})
document.addEventListener ('keypress', function (e) {
console.log ('document scanner barcode');
})
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直在研究和实验。需要考虑的几件事:
基于此,您必须在JavaScript中创建适当的逻辑来处理扫描仪输入。
I've been researching and experimenting. A few things to consider:
Based on this, it's up to you to create the proper logic in your javascript to handle the scanner input.