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

不羁岁月 提交于 2019-12-03 09:38:18

问题


I have the following setup:

  • iPad with Safari browser running a webb-application.
  • Bluetooth barcode-scanner connected/paired with the 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.

The above works fine when running the application on a desktop with an USB-scanner.

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.

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?

Thanks /E


回答1:


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. 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.



来源:https://stackoverflow.com/questions/11418061/listen-to-keypress-in-html-javascript-on-ios-safari-with-bluetooth-scanner-keybo

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