A BOOL
is a signed char
, so when you convert an int
to a BOOL
, you lop off all but the low 8 bits. And in your case, the nonzero bit is not in the low 8 bits. Instead, say
BOOL commandKeyPressed = ([theEvent modifierFlags] & NSCommandKeyMask) != 0;
or just
if ([theEvent modifierFlags] & NSCommandKeyMask)