简体   繁体   English

使用蓝牙扫描仪/键盘在iOS / Safari上听HTML / JavaScript中的按键,无需聚焦字段

[英]Listen to keypress in HTML/JavaScript on iOS/Safari with Bluetooth Scanner/Keyboard without having to focus a field

I have the following setup: 我有以下设置:

  • iPad with Safari browser running a webb-application. 带Safari浏览器的iPad运行webb应用程序。
  • Bluetooth barcode-scanner connected/paired with the iPad. 蓝牙条码扫描器连接/与iPad配对。

My web-application listens to keypress events globally which gives me the possibility to trigger scan functions without having the user to focus a textfield in the webb-application. 我的web应用程序全局监听按键事件,这使我有可能触发扫描功能,而无需用户将文本字段集中在webb应用程序中。

The above works fine when running the application on a desktop with an USB-scanner. 使用USB扫描仪在桌面上运行应用程序时,上述工作正常。

My problem is that the application doesn't trigger keydown(press/up) events until a textfield is focused on the iPad when the bluetooth-scanner is connected. 我的问题是,当连接蓝牙扫描仪时,应用程序不会触发keydown(按下/向上)事件,直到文本字段集中在iPad上。

Is it possible to achieve? 有可能实现吗?

A related question from a while ago: How can I add a Javascript listener to capture input from bluetooth barcode scanner to iPad? 前一个相关问题: 如何添加Javascript监听器来捕获从蓝牙条码扫描器到iPad的输入?

Thanks /E 谢谢/ E.

I believe that with mobile Safari (and most other iOS mobile browsers), keypresses are only detectable by the web app when a form input is infocus. 我相信,对于移动版Safari(以及大多数其他iOS移动浏览器),只有当表单输入为焦点时,才能通过Web应用程序检测到按键。 Your device (without an external keyboard) can't take keypress input without a form input being selected simply because the keyboard would not be up. 您的设备(没有外接键盘)无法在没有选择表单输入的情况下接受按键输入,因为键盘不会启动。

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

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