iPhone JavaScript Character Counts

Gruber wrote recently about the state of iPhone Twitter clients. One of his laments was the poor implementation of character counts for text inputs.

It's a familiar pattern to anyone who's done much client-side scripting. As you type into a textarea, the number of characters you've typed updates. He said the following:

Editing is where Hahlo is a Viking. Typing speed is acceptable — not great, but good enough — and the best of any Twitter web client with a live character count. In most other iPhone clients with a live character count, typing feels dreadfully sluggish. Hahlo’s character count is mostly accurate — which means it’s best-of-breed for iPhone Twitter web clients.

Not a ringing endorsement, that. It got me thinking about what might be the most efficient pattern for implementing this kind of thing.

Now, I don't have an iPhone, but I do have the SDK. Typing with a mouse in the iPhone simulator, I found the interval pattern to be the most responsive. Of the 4 techniques, only the instant updating one failed to provide an accurate count (it was always one key press behind). I'm interested to hear from users of actual iPhones which they think is best (most responsive and most accurate) when using the on-screen keyboard.

Update: I've made the following updates based on reader feedback:

Was this page useful to you? Loading...