i have question javascript caching?
is there way save input keyboard object/element or whatelse in can store user input keyboard when focus not on textbox?
and after focused od textbox, want typed text automatically put textbox?
i need this, example, if in 1 textbox exist function executes 1-2 sec, , if quick select textbox , instantly start typing, first few characters typed in second textbox, because function in first textbox still executing...
which approach best case?
thanks.
this solvable quite easy using jquery think. can try experiments following snippet, should want:
jquery(function() { var inputbuffer = ""; jquery("body").keypress(function(event) { // collect input not being processed input/textarea field inputbuffer += string.fromcharcode(event.charcode); }); jquery("input,textarea").focus(function(event) { // append buffered input text field jquery(this).val( jquery(this).val() + inputbuffer ); // clear buffer inputbuffer = ""; }); jquery("input,textarea").blur(function(event) { // discard input buffer // prevent using input collected while having input/textarea in focus inputbuffer = ""; }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> <p>some non-input element</p> </div> <input type="text" />
Comments
Post a Comment