Fix memory leak in handledKeydownEvents for repeated keydown events

`handledKeydownEvents` leaks when a keydown event 'repeats' (ie. the user holds the key), since we only remove one of the keydowns corresponding to the current keyup event. This PR instead uses a `filter` call, which removes all the keydown events that relate to the keyup and prevents the leak.