I need a function that triggers an event every time every time a word is entered while the browser is focused on the webpage. I figured I’d use jQuery for this and came up with the following which does the job:
$(document).ready(function(){
var target = "808072727373767673738080";
var input = "";
$(window).delegate('*', 'keyup', function (e){
input += e.keyCode;
if(input==target){
alert('philip');
}
if(e.keyCode==13){
input = "";
}
});
});
However I feel that there might be a simpler solution than to use the delegate function..
Any advice or links to other posts?
Give ID to body and use .keyup() for handling the event.
I think this must be more simpler way to do it.