Today is a good day to code

OnKeyPress JavaScript Events on the iPhone

Posted: December 31st, 1969 | Author: | Filed under: Uncategorized | No Comments »

OnKeyPress JavaScript Events on the iPhone

Picture of IrvinSo the iPhone doesn't send keypress JavaScript events as a user is typing into the on-screen keyboard. So how do you simulate it?

Well, I know that setInterval, while very handy uses a lot of memory, and can bog down the interface. I'd use a recursive setTimeout call that triggers only if the client is the iPhone. Also, I'd be careful to manually delete all of my pointers to the DOM. I actually have started doing this anyway to avoid memory leaks in IE. It works O.K., but it can bog down the interface since it calls the garbage collection routine more frequently than it might otherwise, but if you have a big application, it is better than eating up all of the client memory.