Edit in JSFiddle

function saludo(){
   alert("Hola");
}
$("input").keypress(saludo).blur(saludo);
<input type = "text" autofocus />