javascript - jQuery - Detect specific word with .keypress function -


i've been trying jquery detect number of letters entered after each other on keyboard.

actually, wanted achieve is, use .keypress function detect word instead of single character. now, can't type word , press keys @ same time, have program way jquery remembers letters i've typed in before, if write "test", remember "t,e , s" before type in last "t" make if condition come true.

here's tried, don't know how store characters (basically keylogger, single word, used open application):

$(document).keypress(function(e) {   if( e.ctrlkey && ( e.which === 46 ) ) {     alert('ctrl , del pressed!');   } }); 

this way, managed jquery recognize key combination, that's know now.

can me figure out how detect whole world?

thank much.

based on comments:

i think best way go grab text , check if contains item in whitelist.

otherwise if user copy pastes, or moves input, miss characters. hesitate on keyup depends on whitelist etc.

something work.

$( "#target" ).keyup(function() {       var inputtext = $( "#target" ).text();      whitelist.foreach(function(){           if(inputtext.indexof(awhitelistitem) > 0)           {               alert("found it");           }      });   }); 

if curious waiting delay, there lots of great posts


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -