为什么在调试Android手机时只收到一些虚拟键盘事件?

时间:2019-05-30 18:36:16

标签: javascript android google-chrome-devtools

我正在使用JQuery而不是本地电话应用程序制作网页。

我有一个表单(文本)输入元素,用于处理键盘事件以创建HTML列表。我可以在台式机和Android手机上使用所有可以找到的浏览器正常运行。

但是,当我尝试使用Chrome远程调试时,它会在前几个事件之后停止发送键盘事件。

一切都可以在台式机(Chrome / FF dev / IE)和电话(两个Firefox,两个Opera,Dolphin,Mint,Puffin和Chrome)上运行。具体来说,我在虚拟键盘中输入的内容会立即显示在页面的输入中。我知道该脚本正在获取键盘事件,因为该列表出现了(应该在四个字符之后出现。)。

当我在Chrome中进行远程调试时,当输入获得焦点时会收到click事件,而在键入字符时会得到keydown事件。该字符将按预期方式出现在输入中,但从那以后,我再也没有发生任何事件了。

我尝试将侦听器附加到一长串可能的事件中,以查看虚拟键盘是否在第一个字符之后发送“其他”消息。我的keybd条目出现在键盘上方的建议列表中,但是似乎第一个事件之后没有事件发送到全局或局部对象。 $('#input')。click(function(e){

    var  name = '';

    //  get the name by dereferencing 'e'

    console.log('OnClick: ' + name );

}

$('#input').keydown( function( e ) {

var  key = '';

//  get the key by dereferencing 'e'
//     example:
//  key = e.originalEvent.srcElement.value;

console.log('OnKeydown: ');

}

// I have tried adding numerous Event listeners to the Global object (or local) w/o JQuery like this:

self.addEventListener("dispatchKeyEvent", function  ( e ) {
console.log('GLOBAL dispatchKeyEvent');

});

self.addEventListener("OnKeyListener ", function  ( e ) {
console.log('GLOBAL OnKeyListener ');

});

// ... just to see if it is sending other kinds of events that I am missing.

我期望在进行远程调试时从虚拟密钥获取事件。我得到了头几个click和onkeydown事件,然后什么也没有。

我没有收到任何错误消息或警告。唯一的“详细”消息大概是由我的代码中的断点引起的。

[Violation] 'setTimeout' handler took 65ms
(index):866 OnClick
(index):866 OnClick Key: undefined
jquery-3.3.1.min.js:2 
[Violation] 'click' handler took 2416ms
(index):866 OnKeydown
(index):866 Key: C
jquery-3.3.1.min.js:2 
[Violation] 'keydown' handler took 2738ms

这就是死亡的地方...除非我再次单击输入。

0 个答案:

没有答案