Ok, before we think about merging this one in, can you remove the duplication in your code?  The code for this condition and the focus events are the same, so either combine the conditional or create a small function that each condition can call.

I think I prefer to pull it out into a function since it would declare the intent more clearly than a more complex conditional.