键入隐藏的输入字段

Ric*_*rim 2 html jquery jquery-ui barcode jquery-mobile

我手头有一个特殊类型的问题,对此我想从可能已经实施类似问题的人那里得到一些建议。

我有一个客户端使用 EAM 扫描仪扫描条形码,通过蓝牙作为键盘单元连接到移动单元。

在上述移动设备上,我们有一个运行 JQuery Mobile/HTML5 的网络框架。他们希望将扫描仪用于此。我们想要实现的是让扫描仪将条形码拾取到某种不可见的字段,然后这将用于根据扫描的值在 UI 中启用以前禁用的可折叠对象。

我已经对使用文本字段和触发 keyup 事件进行了测试,以在每个字符被传递时继续检查,如果输入的值对应于可折叠的数据属性。这似乎工作正常。

但我不希望用户看到输入字段(它应该完全隐藏)但它仍然需要焦点并能够接受按键。如果我在样式中设置了visibility:none,它就不再触发keyup 事件。

那么,如何创建一个在 UI 中不可见但可以通过代码设置为焦点的输入字段,并且将接受文本以触发 keyup?

我也试过 input type="hidden" 但这似乎不接受输入或焦点。

我的测试代码:

     $(document).ready(function() { 
          $( '#f1' ).collapsible("disable");
          $( '#f1' ).trigger("create");
          $( '#f2' ).collapsible("disable");
          $( '#f2' ).trigger("create");
          var value = ""; //Store entered information
      //Add key handler, to the div including the text field, to avoid other text 
      //  field being blocked out
    $( "#page_wrapper" ).keypress(function(event) {
     //Translate key to char and append 


     value += String.fromCharCode(event.which);

     /*
      * Cut out
      */


     //Iteration here to check all collapsibles if the data value entered is valid for   
     //one of them, after checking 
     //input lenght, to make sure it is a complete EAN barcode 

     //Make sure to clear to limit input
     $( "#scanfield" ).val("");



        //Focusing on the field
        $( '#scanfield' ).focus(); /* CUT */
Run Code Online (Sandbox Code Playgroud)

fre*_*ent 6

您是否尝试过 JQM 课程ui-hidden-accessible

来自JQM CSS

.ui-hidden-accessible {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px,1px,1px,1px);
}
Run Code Online (Sandbox Code Playgroud)