I have this code which is for youtube autocomplete suggestions:
$(function(){
$('#input-field').keyup(function(){
var val = $(this).val();
jQTubeUtil.suggest(val, function(response){
var html = '';
for(s in response.suggestions){
var sug = response.suggestions[s];
html += '<li class="li-class"><a href="#">'+sug+'</a></li>';
}
if (response.suggestions.length)
$('#autocomplete').html(html).show();
else
$('#autocomplete').hide();
});
});
});
How can I STOP a request being made if an arrow key (keycode 40/38) is being pressed?
I know it has something to do with ‘!’ or event ‘.not’ but my efforts did not pay off.
You could simply return, effecitvely halting the function execution, if the key is between those values.