I have the following code – http://jsfiddle.net/vcvsb/1/ – per
$(document).ready(function(e) {
$("input#autocomplete").autocomplete({
source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
});
jQuery("#autocomplete").keypress(function (e) {
if (e.keyCode == 13) {
$('#buttontest').trigger('click');
alert('crap, clicked');
}
});
});
I am trying to set it up so that the user can move down with the arrow keys – hit enter and then keep typing. The problem I am facing – is that as soon as the user selects enter after getting an auto-complete response – it triggers the button click ?
How can I set it up so that:
- A user can use the arrow keys to move to a selection, then hit enter
- After hitting enter, the user can keep typing
- If the user hits enter again, it triggers the click
?
well sort of a hack but works http://jsfiddle.net/amantur/hhUdV/ . You need to keep count of how may times ENTER is clicked. When it is second time trigger button click.