1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// From http://cocoadev.com/index.pl?GameKeyboardHandlingAlmost
// This works around an AppKit bug, where key up events while holding
// down the command key don't get sent to the key window.
- (void)sendEvent:(NSEvent *)event
{
    if ([event type] == NSFlagsChanged ) {

        NSUInteger flags = [event modifierFlags];

        if ((flags & NSShiftKeyMask) == 0) {
            _glfwInput.Key[GLFW_KEY_LSHIFT] = 0;
            _glfwInput.Key[GLFW_KEY_RSHIFT] = 0;
        }
    }

    if( [event type] == NSKeyUp && ( [event modifierFlags] & NSCommandKeyMask ) )
    {
        [[self keyWindow] sendEvent:event];
    }
    else
    {
        [super sendEvent:event];
    }
}