A few years later, I donβt see what is the difference between the example in the question and what I wrote, so this update
["paste", "keypress", "drop"].forEach(event => input_element.addEventListener(event, self.hide, false));
ORIGINAL RESPONSE
The first thing that came to mind
function hide(){
self.hide();
}
input_element.addEventListener("paste", hide, false);
input_element.addEventListener("keypress", hide, false);
input_element.addEventListener("drop", hide, false);
source
share