The eventstate was checked instead of the current event being handled, causing the check to be invalid in some cases.