I have had a similar issue before. As far as I know, the browser issues no events when the user pastes via right click, nor when they select from the list of previously used values.
I ended up solving it in a good enough way by additionally binding my event handler to the blur event. The only case this didn't catch was when they paste a value with the mouse, then hit the Enter key to submit. I was able to get around this through a little hackery:
$(element)
.bind('keydown blur', handlerFunction)
.keydown(function(event) {
if (event.keyCode === 13 /* Enter Key */) {
event.preventDefault();
event.stopPropagation();
}
})
.keyup(function(event) {
if (event.keyCode === 13 /* Enter Key */) {
$(this).closest('form').submit();
}
});
Essentially, this works because jQuery will execute the events in the order they were bound. Normally, form submission takes place on the keydown of an Enter keypress. In order to give the keyup handler time to do its magic, you need to delay that form submission until the keyup event happens, so the other keyup handler can run first.
Now, you said that you were using a plugin that adds a delay before reacting to the users event. That means you may not be able to use this technique verbatim. One thing that might work instead would be to call the handler function directly before allowing the form to submit. To do that, you would change the last keyup handler to:
.keyup(function(event) { // Part 2
if (event.keyCode === 13 /* Enter Key */) {
handlerFunction.call(this, event); // force it to happen now
$(this).closest('form').submit();
}
});
As Josh K mentioned before, you could simply bind something to the submit event on your form to do something similar. If you are doing Ajax there, though, be sure to set async: false
in the passed options, because otherwise the form will go ahead and submit without waiting for the call to complete.