Hello, myInput.value is one keystroke behind when I examine it in a keyPress event handler. So if the users types "a", myInput.value gives me "". Then when the user types "b", myInput.value gives me "a", and so it. The value doesn't seem to get updated with the character input by the keystroke that triggered the event. What am I doing wrong? thanks -Morgan
+5
A:
Use the keyUp event, it should definitely give you the value you are looking for.
sandesh247
2009-02-11 16:48:44
Yep. The new keypress is applied to the value *after* calling onkeypress — as long as you don't cancel that event by returning false from your handler. Keyup, on the other hand, happens after the keypress has finished.
bobince
2009-02-11 18:04:11
great. works perfect. thanks.
morgancodes
2009-02-11 19:01:35