关键事件犯规在Firefox Android上触发时,字的建议是在 [英] Key event doesnt trigger in Firefox on Android when word suggestion is on

查看:126
本文介绍了关键事件犯规在Firefox Android上触发时,字的建议是在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有触发自动完成搜索,同时输入搜索字段。我有它KEYUP触发。这工作完全在大多数浏览器,但在Firefox Android上,这是行不通的。这似乎是keyup事件在打字时不会被触发。仅当字的建议被打开在Android键盘设置情况。

I have a search field that triggers an autocomplete search while typing. I have it trigger on keyup. This works perfectly in most browsers, but in Firefox on Android, this does not work. It seems like the keyup event is not triggered while typing. This only happens if word suggestions is turned on in the Android keyboard settings.

我在谷歌搜索自动完成搜索工作在那里同样的设置即见,因此它显然是可以做到的。我不知道怎么样?它是一个特殊的事件中,我需要听这个工作?

I see on Google search that the autocomplete search works there for the same setup, so it is obviously possible to do. I wonder how? Is it a special event I need to listen to for this to work?

此外我试图听的事件改变,KeyDown和关键preSS,但没有被触发。

Additionally I have tried to listen to the events change, keydown and keypress, but none is triggered.

HTML:

<input type="text" id="searchField" 
 autocomplete="off" spellcheck="false" autocorrect="off" />

jQuery的事件绑定:

jQuery event binding:

  $('#searchField').keyup(function (e) {
    var searchValue = $(this).val();
    searchApi._executeAutocomplete(searchValue);
  });

注意:
有时,键事件的的触发,这通常是打了一个密钥不导致形成一个字的过程。最明显的这里是<大骨节病>输入,它始终触发。另一种是<大骨节病>空格,这将触发因为没有字包含一个空间,因为空间是完成了一个词的定义。 <大骨节病>退格触发器的如果的删除的最后一个字符不是一个字内。这意味着它会触发如果你只是删除一个单词的最后剩余的字母(所以它是该领域的下一个空间的开始,或光标),但如果你在一个单词的末尾删除了一些字,其中光标仍在立即一封信以下。基本上,关键事件不会触发如果键preSS导致一些字的建议,从键盘的应用程序。

Note:
Sometimes, the key event is triggered, which is typically hitting a key that is not resulting in the process of forming a word. The most obvious here is Enter, which always triggers. Another is Space, which triggers because no word contain a space since space is the definition of a word completed. Backspace triggers if the the last character deleted was not within a word. This means it triggers if you just deleted the last remaining letter of a word (so it is the start of the field, or cursor following a space), but not if you deleted some characters at the end of a word where the cursor is still immediately following a letter. Basically, the key event is not triggered if the key press results in some kind of word suggestion from the keyboard app.

作为一个方面说明,我可以说,一切工作正常Chrome浏览器在同一设备上。

As a side note, I can say that everything works fine in Chrome on the same device.

推荐答案

您可以使用<一个href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#event-input-input"><$c$c>input事件相反,在Firefox为我工作在Android上。 你可以事件处理程序绑定到两个输入 KEYUP 向后兼容的事件,但在大多数现代浏览器,这将触发这两个

You can use the input event instead, that worked for me in Firefox on Android. You could bind event handlers to both input and keyup events for backwards compatibility, but in most modern browsers this will fire both:

$('#searchField').bind('input keyup', function(e){
    var searchValue = $(this).val();
    searchApi._executeAutocomplete(searchValue);
});

下面示例: http://jsfiddle.net/JQ928/3/

这篇关于关键事件犯规在Firefox Android上触发时,字的建议是在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆