[英]How to disable keydown processing when using autocomplete with FF (or IE) in a text box using javascript?
In order to control what fields the Enter key affects, I wrote the folowing javascript which gets called on the keydown event: 为了控制Enter键影响哪些字段,我编写了以下javascript,它在keydown事件中被调用:
function editorEnter(e)
{
var key;
if (window.event) key = window.event.keyCode; //IE
else key = e.which; //firefox
if (key == 13) addEditorRow('EditorTable');
}
Here's how it is used in the context of a text field: 以下是在文本字段的上下文中使用它的方式:
<input type="text" name="EditorSurname" class="EditorSurnameText"
value="" onkeydown="editorEnter(event);" onkeyup="EnableSave();"/>
The problem is that in FireFox with autocomplete enabled, if I select a value from the autocomplete dropdown and press enter, it does not perform the autocomplete and adds the row to the table. 问题在于,在启用了自动完成功能的FireFox中,如果我从自动完成功能下拉列表中选择一个值并按Enter,则它不会执行自动完成功能,而是将行添加到表中。 Is there a way to disbale the enter key functionality when selecting autocomplete?
选择自动完成功能时,是否可以取消Enter键功能?
查看以下相关问题: 捕获Enter键,但在选择浏览器的自动完成建议时则不行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.