Modifier Keys:
Filter:
Reference | GUI | Platform > macOS

Modifier Keys

macOS Modifier key reference
NOTE: This document might be outdated..

An integer bit field indicating the modifier keys in effect. You can examine individual flag settings using the C bitwise AND operator.

65536 NSAlphaShiftKeyMaskSet if Caps Lock key is pressed.
131072 NSShiftKeyMaskSet if Shift key is pressed.
262144 NSControlKeyMaskSet if Control key is pressed.
524288 NSAlternateKeyMaskSet if Option or Alternate key is pressed.
1048576 NSCommandKeyMaskSet if Command key is pressed.
2097152 NSNumericPadKeyMaskSet if any key in the numeric keypad is pressed. The numeric keypad is generally on the right side of the keyboard.
4194304 NSHelpKeyMaskSet if the Help key is pressed.
8388608 NSFunctionKeyMaskSet if any function key is pressed. The function keys include the F keys at the top of most keyboards (F1, F2, and so on) and the navigation keys in the center of most keyboards (Help, Forward Delete, Home, End, Page Up, Page Down, and the arrow keys).
Arrow keysArrow keys have an extra modifier value of 10485760 so for a shift arrow key do a bitwise 'or' with the shift mask: 10485760 | 131072 = 10616832 // this is the mask for shift arrow key

Three usage examples, direct and with helper methods isCaps, isShift, isCtrl, isAlt, isCmd, isNumPad, isHelp, isFun: