The event base architecture of javascript combined with the single threaded event loop creates a situation where a keyup event can occasionally fire before the keydown. This happens when holding a key and pressing and releasing other keys. This leads to a situation where keys can become suck in application state. The solution is to timestamp keydown and keyup events. This allows you to ignore key down event if they've occurred after the keyup even has already been fired.