Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

An attempt to map modifier key events to regular key up/key down events...

View gist:950169
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
// FIXME: does not work as intended if both left and right modifier key are pressed simultaneously!!!
 
- (NSUInteger)modifierFlagMaskForKeyCode:(unsigned short)keyCode
{
switch(keyCode)
{
case 54: // right cmd
case 55: // left cmd
return NSCommandKeyMask;
 
case 56: // left shift
case 60: // right shift
return NSShiftKeyMask;
 
case 57: // caps lock
return NSAlphaShiftKeyMask;
 
case 58: // left alt
case 61: // right alt
return NSAlternateKeyMask;
 
case 59: // left ctrl
case 62: // right ctrl
return NSControlKeyMask;
}
return 0;
}
 
- (void)flagsChanged:(NSEvent *)event
{
if([event modifierFlags] & [self modifierFlagMaskForKeyCode:[event keyCode]])
NSLog(@"down: %u", (unsigned int)[event keyCode]);
else
NSLog(@"up: %u", (unsigned int)[event keyCode]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.