You can just do `event.which != null`, which is a bit shorter than the `typeof` check (and is what jQuery does, fwiw). Also I think that code would be clearer if the third branch were in an `else`.