久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何添加 Javascript 偵聽器以捕獲從藍牙條碼掃描

How can I add a Javascript listener to capture input from bluetooth barcode scanner to iPad?(如何添加 Javascript 偵聽器以捕獲從藍牙條碼掃描器到 iPad 的輸入?)
本文介紹了如何添加 Javascript 偵聽器以捕獲從藍牙條碼掃描器到 iPad 的輸入?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在 iPad 上用 JavaScript 記錄擊鍵時遇到問題.以下腳本適用于 Chrome 和 Safari,但不適用于 iPad Safari.藍牙條碼掃描器發送 12 位數字作為按鍵,然后發送一個返回字符.有人有什么想法嗎?

I'm having trouble logging keystrokes in javascript on the iPad. The following script works on Chrome and Safari, but not iPad Safari. The bluetooth barcode scanner sends 12 digits as keystrokes, then sends a return character. Does anyone have any ideas?

我想你需要一個 iPad 來試試這個 :)

I think you will need an iPad to try this out :)

謝謝,標記

$(document).ready(function(){
 $(document).keypress(function(e){
  if( e.keyCode == 13){
   alert($('#barcode').attr('value'));
   $('#barcode').attr('value','');
  }
  else{
   var key = String.fromCharCode(e.which);
   var new_val = $('#barcode').attr('value') + key;
   $('#barcode').attr('value',new_val);
  }
 });
});

推薦答案

iOS 版 Safari 不會在非表單組件的 DOM 元素上觸發鍵盤事件.這包括通常用于捕獲頁面上任何位置的擊鍵的文檔和正文.

Safari for iOS doesn't trigger keyboard events on DOM elements that are not components of a form. This includes the document and body which are usually used to capture keystrokes anywhere on the page.

在文檔或頁面正文上觸發擊鍵事件的唯一方法是在輸入或文本區域中觸發它.在這種情況下,事件將正確地冒泡"到正文和文檔.

The only way to trigger a keystroke event on document or body of a page is to trigger it in an input or textarea. In that case, the event will correctly 'bubble' to the body and document.

但是,這可能是一個問題,因為 iOS 版 Safari 不允許我們從 javascript 中提供元素焦點.

However, this might be a problem because Safari for iOS doesn't allow us to give an element focus from javascript.

目前,我們使用的解決方案是用戶必須在開始第一次掃描之前點擊輸入字段,然后輸入字段移出屏幕但保持焦點.

At the moment, we are using a solution where user has to click on an input field before starting the first scan, and the input field is then moved off-screen but retains focus.

如果有人有更好的解決方案,請分享.

If someone has a better solution, please share.

這篇關于如何添加 Javascript 偵聽器以捕獲從藍牙條碼掃描器到 iPad 的輸入?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 免费中文字幕日韩欧美 | 精品久久久久久 | 久久亚洲精品视频 | 亚洲成人一级 | 免费一级大片 | 欧美一区二区三区视频在线观看 | 男人天堂999 | 成人特区 | 久久久久久久久久久一区二区 | 欧美不卡视频一区发布 | 亚洲精品久久久久久国产精华液 | 日本三级电影在线观看视频 | 成人精品一区二区 | 一区二区三区在线免费观看 | 伊人艹 | 久久久日韩精品一区二区三区 | 91在线精品秘密一区二区 | 久草99| 久久99精品久久 | 青青久久av北条麻妃海外网 | 欧美一区二区三区视频在线 | 91天堂网| 国产精品精品久久久 | 国产一级特黄视频 | 色综合久久伊人 | 欧美一区二区三区在线视频 | 国内久久 | 欧美激情区| 国产欧美精品在线 | 久久小视频 | 亚洲视频中文字幕 | 久久精品亚洲 | 日本视频中文字幕 | 日日夜夜视频 | 欧美精品综合在线 | 成人精品一区二区三区 | 国产成人免费视频 | 日本又色又爽又黄的大片 | 精品一区二区三区在线观看 | 色又黄又爽网站www久久 | 蜜月aⅴ免费一区二区三区 99re在线视频 |