Is there anyway around this?
If i pressed 'St', by the time i had pressed the t, if i were to output the input textfield.value in the onkeypress/onkeyup/etc function, i would only get 'S'??
How do i get rid of this lag?
Is there anyway around this?
If i pressed 'St', by the time i had pressed the t, if i were to output the input textfield.value in the onkeypress/onkeyup/etc function, i would only get 'S'??
How do i get rid of this lag?
use the keyup event instead of keypress. keydown will show the before-keystroke value, as will keypress (apparently).
Because the keystroke is not registered until keyup event occurs. So you should detect onkeyup event instead of onkeypress.
Within the keypress event, it's still possible to prevent the typed character from registering, so the input's value canot be updated until after the keypress event. You can use the keyup event instead, or use window.setTimeout() to set up a delay.