I am trying to create a simple search string. How can I call a function immediately after entering one letter in the input field? I used .keyup, but this seems useless because when a diacritical character is typed, the function runs three times.
<input id="text" type="text" />
<div></div>
<script>
$('#text').keyup(function(){
$('div').append('TEST'+$(this).val());
});
</script>
The code above works fine if you do not type any diacritical character: ą, ś, ł, ż, ź, ć, etc.
I can not use .keypress or .keydown, because they run the function before entering the character.
EDIT LATER:
I know that my example may not be clear enough to understand the problem, but ... In my real code, every time a letter is typed, an SQLite query is executed. If the type is diacritical or uppercase, the query is executed three or two times, which slows down the entire script. It will not make much difference if you run the script in the computer’s web browser, but there is a significant lag in mobile browsers.
source
share