I’m trying to get the keydown event to fire whenever the Delete key is pressed while in a certain context of my web application. For example, I have an online file system implemented, and when that view is in use, I want the keydown event to be active.
However, I also have certain popups that come up over the page when certain actions are performed. When these popups are visible, I’d like the keydown event to be disabled, because that event interferes with their functionality. The working event code that I have currently doesn’t do this:
$(document).keydown(function(event){
if(event.which === 46 && ($('.selected').size() > 0)){
saveDelete();
}
});
Is there a way to have this keydown event stop firing under certain conditions?
I think you want .length (no parenthesis) rather than .size() ?