I’m not sure how to pass the specific keystroke through the bind method..
$(document).bind('keyup', event, keyup_handler(event));
This is my lucky failing guess..
This is the method it gets passed too..
var keyup_handler = function(e){
if (e.keyCode == 27) {
close_lightbox();
return false;
};
};
Another failing variation :
var keyup_handler = function(e){
if (e.keyCode == 27) {
close_lightbox();
return false;
};
};
$(document).bind('keyup', keyup_handler(e));
Which returns:
e is not defined
I think you might misunderstand the
bindAPI.With your code, you’re telling jQuery to bind
undefinedtokeyup:keyup_handlerby writingkeyup_handler(...). It returnsundefined, which is what is passed to the jQuerybindcall.event) is also undefined.Instead,