1

I want to execute Jquery Autocomplete when I hit ctrl-enter key. So when I hit ctrl-enter key all the items should be listed for user.

$("#textarea").autocomplete({
    source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
});

Now in the above code, when I hit ctrl-enter in my textarea, all the items should be shown to the user

Mark Schultheiss
  • 32,614
  • 12
  • 69
  • 100
Parag A
  • 443
  • 2
  • 8
  • 20

2 Answers2

1

Working Fiddle

$("#textarea").autocomplete({
    source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"],
    minLength: 0
});

$('#textarea').keydown(function (e) {
  if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) {
       $("#textarea").autocomplete("search","");
  }
});
Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
  • Hey there, I tried this option. Its great. But there are few times when it does not work because the script goes into some infinite loop and windows prompt me to stop the script. – Parag A Apr 22 '13 at 02:37
0

See Ctrl+Enter jQuery in TEXTAREA.

I'm not sure why you need autocomplete if if you're not completing. You can just trigger an JQuery ajax request and list whatever you want when the ctrl + enter is pressed as shown on the link above.

OR you could trigger an autocomplete to execute a script that lists whatever you want.

Community
  • 1
  • 1
Meezaan-ud-Din
  • 1,213
  • 16
  • 21
  • The reason I want to use jquery Autocomplete is beccause it shows the list of option and allows users to select the item. How easy would it be to achieve something like jquery autocomplete ? Please let me know – Parag A Apr 22 '13 at 02:34