Skip to content

Instantly share code, notes, and snippets.

@stephancasas
Last active October 25, 2024 01:28
Show Gist options
  • Save stephancasas/74c4621e2492fb875f0f42778d432973 to your computer and use it in GitHub Desktop.
Save stephancasas/74c4621e2492fb875f0f42778d432973 to your computer and use it in GitHub Desktop.
macOS Modifier Keys Decimal Values Map
{
"65536": [
"alphashift"
],
"131072": [
"shift"
],
"196608": [
"alphashift",
"shift"
],
"262144": [
"control"
],
"327680": [
"alphashift",
"control"
],
"393216": [
"shift",
"control"
],
"458752": [
"alphashift",
"shift",
"control"
],
"524288": [
"option"
],
"589824": [
"alphashift",
"option"
],
"655360": [
"shift",
"option"
],
"720896": [
"alphashift",
"shift",
"option"
],
"786432": [
"control",
"option"
],
"851968": [
"alphashift",
"control",
"option"
],
"917504": [
"shift",
"control",
"option"
],
"983040": [
"alphashift",
"shift",
"control",
"option"
],
"1048576": [
"command"
],
"1114112": [
"alphashift",
"command"
],
"1179648": [
"shift",
"command"
],
"1245184": [
"alphashift",
"shift",
"command"
],
"1310720": [
"control",
"command"
],
"1376256": [
"alphashift",
"control",
"command"
],
"1441792": [
"shift",
"control",
"command"
],
"1507328": [
"alphashift",
"shift",
"control",
"command"
],
"1572864": [
"option",
"command"
],
"1638400": [
"alphashift",
"option",
"command"
],
"1703936": [
"shift",
"option",
"command"
],
"1769472": [
"alphashift",
"shift",
"option",
"command"
],
"1835008": [
"control",
"option",
"command"
],
"1900544": [
"alphashift",
"control",
"option",
"command"
],
"1966080": [
"shift",
"control",
"option",
"command"
],
"2031616": [
"alphashift",
"shift",
"control",
"option",
"command"
],
"2097152": [
"numericpad"
],
"2162688": [
"alphashift",
"numericpad"
],
"2228224": [
"shift",
"numericpad"
],
"2293760": [
"alphashift",
"shift",
"numericpad"
],
"2359296": [
"control",
"numericpad"
],
"2424832": [
"alphashift",
"control",
"numericpad"
],
"2490368": [
"shift",
"control",
"numericpad"
],
"2555904": [
"alphashift",
"shift",
"control",
"numericpad"
],
"2621440": [
"option",
"numericpad"
],
"2686976": [
"alphashift",
"option",
"numericpad"
],
"2752512": [
"shift",
"option",
"numericpad"
],
"2818048": [
"alphashift",
"shift",
"option",
"numericpad"
],
"2883584": [
"control",
"option",
"numericpad"
],
"2949120": [
"alphashift",
"control",
"option",
"numericpad"
],
"3014656": [
"shift",
"control",
"option",
"numericpad"
],
"3080192": [
"alphashift",
"shift",
"control",
"option",
"numericpad"
],
"3145728": [
"command",
"numericpad"
],
"3211264": [
"alphashift",
"command",
"numericpad"
],
"3276800": [
"shift",
"command",
"numericpad"
],
"3342336": [
"alphashift",
"shift",
"command",
"numericpad"
],
"3407872": [
"control",
"command",
"numericpad"
],
"3473408": [
"alphashift",
"control",
"command",
"numericpad"
],
"3538944": [
"shift",
"control",
"command",
"numericpad"
],
"3604480": [
"alphashift",
"shift",
"control",
"command",
"numericpad"
],
"3670016": [
"option",
"command",
"numericpad"
],
"3735552": [
"alphashift",
"option",
"command",
"numericpad"
],
"3801088": [
"shift",
"option",
"command",
"numericpad"
],
"3866624": [
"alphashift",
"shift",
"option",
"command",
"numericpad"
],
"3932160": [
"control",
"option",
"command",
"numericpad"
],
"3997696": [
"alphashift",
"control",
"option",
"command",
"numericpad"
],
"4063232": [
"shift",
"control",
"option",
"command",
"numericpad"
],
"4128768": [
"alphashift",
"shift",
"control",
"option",
"command",
"numericpad"
],
"4194304": [
"help"
],
"4259840": [
"alphashift",
"help"
],
"4325376": [
"shift",
"help"
],
"4390912": [
"alphashift",
"shift",
"help"
],
"4456448": [
"control",
"help"
],
"4521984": [
"alphashift",
"control",
"help"
],
"4587520": [
"shift",
"control",
"help"
],
"4653056": [
"alphashift",
"shift",
"control",
"help"
],
"4718592": [
"option",
"help"
],
"4784128": [
"alphashift",
"option",
"help"
],
"4849664": [
"shift",
"option",
"help"
],
"4915200": [
"alphashift",
"shift",
"option",
"help"
],
"4980736": [
"control",
"option",
"help"
],
"5046272": [
"alphashift",
"control",
"option",
"help"
],
"5111808": [
"shift",
"control",
"option",
"help"
],
"5177344": [
"alphashift",
"shift",
"control",
"option",
"help"
],
"5242880": [
"command",
"help"
],
"5308416": [
"alphashift",
"command",
"help"
],
"5373952": [
"shift",
"command",
"help"
],
"5439488": [
"alphashift",
"shift",
"command",
"help"
],
"5505024": [
"control",
"command",
"help"
],
"5570560": [
"alphashift",
"control",
"command",
"help"
],
"5636096": [
"shift",
"control",
"command",
"help"
],
"5701632": [
"alphashift",
"shift",
"control",
"command",
"help"
],
"5767168": [
"option",
"command",
"help"
],
"5832704": [
"alphashift",
"option",
"command",
"help"
],
"5898240": [
"shift",
"option",
"command",
"help"
],
"5963776": [
"alphashift",
"shift",
"option",
"command",
"help"
],
"6029312": [
"control",
"option",
"command",
"help"
],
"6094848": [
"alphashift",
"control",
"option",
"command",
"help"
],
"6160384": [
"shift",
"control",
"option",
"command",
"help"
],
"6225920": [
"alphashift",
"shift",
"control",
"option",
"command",
"help"
],
"6291456": [
"numericpad",
"help"
],
"6356992": [
"alphashift",
"numericpad",
"help"
],
"6422528": [
"shift",
"numericpad",
"help"
],
"6488064": [
"alphashift",
"shift",
"numericpad",
"help"
],
"6553600": [
"control",
"numericpad",
"help"
],
"6619136": [
"alphashift",
"control",
"numericpad",
"help"
],
"6684672": [
"shift",
"control",
"numericpad",
"help"
],
"6750208": [
"alphashift",
"shift",
"control",
"numericpad",
"help"
],
"6815744": [
"option",
"numericpad",
"help"
],
"6881280": [
"alphashift",
"option",
"numericpad",
"help"
],
"6946816": [
"shift",
"option",
"numericpad",
"help"
],
"7012352": [
"alphashift",
"shift",
"option",
"numericpad",
"help"
],
"7077888": [
"control",
"option",
"numericpad",
"help"
],
"7143424": [
"alphashift",
"control",
"option",
"numericpad",
"help"
],
"7208960": [
"shift",
"control",
"option",
"numericpad",
"help"
],
"7274496": [
"alphashift",
"shift",
"control",
"option",
"numericpad",
"help"
],
"7340032": [
"command",
"numericpad",
"help"
],
"7405568": [
"alphashift",
"command",
"numericpad",
"help"
],
"7471104": [
"shift",
"command",
"numericpad",
"help"
],
"7536640": [
"alphashift",
"shift",
"command",
"numericpad",
"help"
],
"7602176": [
"control",
"command",
"numericpad",
"help"
],
"7667712": [
"alphashift",
"control",
"command",
"numericpad",
"help"
],
"7733248": [
"shift",
"control",
"command",
"numericpad",
"help"
],
"7798784": [
"alphashift",
"shift",
"control",
"command",
"numericpad",
"help"
],
"7864320": [
"option",
"command",
"numericpad",
"help"
],
"7929856": [
"alphashift",
"option",
"command",
"numericpad",
"help"
],
"7995392": [
"shift",
"option",
"command",
"numericpad",
"help"
],
"8060928": [
"alphashift",
"shift",
"option",
"command",
"numericpad",
"help"
],
"8126464": [
"control",
"option",
"command",
"numericpad",
"help"
],
"8192000": [
"alphashift",
"control",
"option",
"command",
"numericpad",
"help"
],
"8257536": [
"shift",
"control",
"option",
"command",
"numericpad",
"help"
],
"8323072": [
"alphashift",
"shift",
"control",
"option",
"command",
"numericpad",
"help"
],
"8388608": [
"function"
],
"8454144": [
"alphashift",
"function"
],
"8519680": [
"shift",
"function"
],
"8585216": [
"alphashift",
"shift",
"function"
],
"8650752": [
"control",
"function"
],
"8716288": [
"alphashift",
"control",
"function"
],
"8781824": [
"shift",
"control",
"function"
],
"8847360": [
"alphashift",
"shift",
"control",
"function"
],
"8912896": [
"option",
"function"
],
"8978432": [
"alphashift",
"option",
"function"
],
"9043968": [
"shift",
"option",
"function"
],
"9109504": [
"alphashift",
"shift",
"option",
"function"
],
"9175040": [
"control",
"option",
"function"
],
"9240576": [
"alphashift",
"control",
"option",
"function"
],
"9306112": [
"shift",
"control",
"option",
"function"
],
"9371648": [
"alphashift",
"shift",
"control",
"option",
"function"
],
"9437184": [
"command",
"function"
],
"9502720": [
"alphashift",
"command",
"function"
],
"9568256": [
"shift",
"command",
"function"
],
"9633792": [
"alphashift",
"shift",
"command",
"function"
],
"9699328": [
"control",
"command",
"function"
],
"9764864": [
"alphashift",
"control",
"command",
"function"
],
"9830400": [
"shift",
"control",
"command",
"function"
],
"9895936": [
"alphashift",
"shift",
"control",
"command",
"function"
],
"9961472": [
"option",
"command",
"function"
],
"10027008": [
"alphashift",
"option",
"command",
"function"
],
"10092544": [
"shift",
"option",
"command",
"function"
],
"10158080": [
"alphashift",
"shift",
"option",
"command",
"function"
],
"10223616": [
"control",
"option",
"command",
"function"
],
"10289152": [
"alphashift",
"control",
"option",
"command",
"function"
],
"10354688": [
"shift",
"control",
"option",
"command",
"function"
],
"10420224": [
"alphashift",
"shift",
"control",
"option",
"command",
"function"
],
"10485760": [
"numericpad",
"function"
],
"10551296": [
"alphashift",
"numericpad",
"function"
],
"10616832": [
"shift",
"numericpad",
"function"
],
"10682368": [
"alphashift",
"shift",
"numericpad",
"function"
],
"10747904": [
"control",
"numericpad",
"function"
],
"10813440": [
"alphashift",
"control",
"numericpad",
"function"
],
"10878976": [
"shift",
"control",
"numericpad",
"function"
],
"10944512": [
"alphashift",
"shift",
"control",
"numericpad",
"function"
],
"11010048": [
"option",
"numericpad",
"function"
],
"11075584": [
"alphashift",
"option",
"numericpad",
"function"
],
"11141120": [
"shift",
"option",
"numericpad",
"function"
],
"11206656": [
"alphashift",
"shift",
"option",
"numericpad",
"function"
],
"11272192": [
"control",
"option",
"numericpad",
"function"
],
"11337728": [
"alphashift",
"control",
"option",
"numericpad",
"function"
],
"11403264": [
"shift",
"control",
"option",
"numericpad",
"function"
],
"11468800": [
"alphashift",
"shift",
"control",
"option",
"numericpad",
"function"
],
"11534336": [
"command",
"numericpad",
"function"
],
"11599872": [
"alphashift",
"command",
"numericpad",
"function"
],
"11665408": [
"shift",
"command",
"numericpad",
"function"
],
"11730944": [
"alphashift",
"shift",
"command",
"numericpad",
"function"
],
"11796480": [
"control",
"command",
"numericpad",
"function"
],
"11862016": [
"alphashift",
"control",
"command",
"numericpad",
"function"
],
"11927552": [
"shift",
"control",
"command",
"numericpad",
"function"
],
"11993088": [
"alphashift",
"shift",
"control",
"command",
"numericpad",
"function"
],
"12058624": [
"option",
"command",
"numericpad",
"function"
],
"12124160": [
"alphashift",
"option",
"command",
"numericpad",
"function"
],
"12189696": [
"shift",
"option",
"command",
"numericpad",
"function"
],
"12255232": [
"alphashift",
"shift",
"option",
"command",
"numericpad",
"function"
],
"12320768": [
"control",
"option",
"command",
"numericpad",
"function"
],
"12386304": [
"alphashift",
"control",
"option",
"command",
"numericpad",
"function"
],
"12451840": [
"shift",
"control",
"option",
"command",
"numericpad",
"function"
],
"12517376": [
"alphashift",
"shift",
"control",
"option",
"command",
"numericpad",
"function"
],
"12582912": [
"help",
"function"
],
"12648448": [
"alphashift",
"help",
"function"
],
"12713984": [
"shift",
"help",
"function"
],
"12779520": [
"alphashift",
"shift",
"help",
"function"
],
"12845056": [
"control",
"help",
"function"
],
"12910592": [
"alphashift",
"control",
"help",
"function"
],
"12976128": [
"shift",
"control",
"help",
"function"
],
"13041664": [
"alphashift",
"shift",
"control",
"help",
"function"
],
"13107200": [
"option",
"help",
"function"
],
"13172736": [
"alphashift",
"option",
"help",
"function"
],
"13238272": [
"shift",
"option",
"help",
"function"
],
"13303808": [
"alphashift",
"shift",
"option",
"help",
"function"
],
"13369344": [
"control",
"option",
"help",
"function"
],
"13434880": [
"alphashift",
"control",
"option",
"help",
"function"
],
"13500416": [
"shift",
"control",
"option",
"help",
"function"
],
"13565952": [
"alphashift",
"shift",
"control",
"option",
"help",
"function"
],
"13631488": [
"command",
"help",
"function"
],
"13697024": [
"alphashift",
"command",
"help",
"function"
],
"13762560": [
"shift",
"command",
"help",
"function"
],
"13828096": [
"alphashift",
"shift",
"command",
"help",
"function"
],
"13893632": [
"control",
"command",
"help",
"function"
],
"13959168": [
"alphashift",
"control",
"command",
"help",
"function"
],
"14024704": [
"shift",
"control",
"command",
"help",
"function"
],
"14090240": [
"alphashift",
"shift",
"control",
"command",
"help",
"function"
],
"14155776": [
"option",
"command",
"help",
"function"
],
"14221312": [
"alphashift",
"option",
"command",
"help",
"function"
],
"14286848": [
"shift",
"option",
"command",
"help",
"function"
],
"14352384": [
"alphashift",
"shift",
"option",
"command",
"help",
"function"
],
"14417920": [
"control",
"option",
"command",
"help",
"function"
],
"14483456": [
"alphashift",
"control",
"option",
"command",
"help",
"function"
],
"14548992": [
"shift",
"control",
"option",
"command",
"help",
"function"
],
"14614528": [
"alphashift",
"shift",
"control",
"option",
"command",
"help",
"function"
],
"14680064": [
"numericpad",
"help",
"function"
],
"14745600": [
"alphashift",
"numericpad",
"help",
"function"
],
"14811136": [
"shift",
"numericpad",
"help",
"function"
],
"14876672": [
"alphashift",
"shift",
"numericpad",
"help",
"function"
],
"14942208": [
"control",
"numericpad",
"help",
"function"
],
"15007744": [
"alphashift",
"control",
"numericpad",
"help",
"function"
],
"15073280": [
"shift",
"control",
"numericpad",
"help",
"function"
],
"15138816": [
"alphashift",
"shift",
"control",
"numericpad",
"help",
"function"
],
"15204352": [
"option",
"numericpad",
"help",
"function"
],
"15269888": [
"alphashift",
"option",
"numericpad",
"help",
"function"
],
"15335424": [
"shift",
"option",
"numericpad",
"help",
"function"
],
"15400960": [
"alphashift",
"shift",
"option",
"numericpad",
"help",
"function"
],
"15466496": [
"control",
"option",
"numericpad",
"help",
"function"
],
"15532032": [
"alphashift",
"control",
"option",
"numericpad",
"help",
"function"
],
"15597568": [
"shift",
"control",
"option",
"numericpad",
"help",
"function"
],
"15663104": [
"alphashift",
"shift",
"control",
"option",
"numericpad",
"help",
"function"
],
"15728640": [
"command",
"numericpad",
"help",
"function"
],
"15794176": [
"alphashift",
"command",
"numericpad",
"help",
"function"
],
"15859712": [
"shift",
"command",
"numericpad",
"help",
"function"
],
"15925248": [
"alphashift",
"shift",
"command",
"numericpad",
"help",
"function"
],
"15990784": [
"control",
"command",
"numericpad",
"help",
"function"
],
"16056320": [
"alphashift",
"control",
"command",
"numericpad",
"help",
"function"
],
"16121856": [
"shift",
"control",
"command",
"numericpad",
"help",
"function"
],
"16187392": [
"alphashift",
"shift",
"control",
"command",
"numericpad",
"help",
"function"
],
"16252928": [
"option",
"command",
"numericpad",
"help",
"function"
],
"16318464": [
"alphashift",
"option",
"command",
"numericpad",
"help",
"function"
],
"16384000": [
"shift",
"option",
"command",
"numericpad",
"help",
"function"
],
"16449536": [
"alphashift",
"shift",
"option",
"command",
"numericpad",
"help",
"function"
],
"16515072": [
"control",
"option",
"command",
"numericpad",
"help",
"function"
],
"16580608": [
"alphashift",
"control",
"option",
"command",
"numericpad",
"help",
"function"
],
"16646144": [
"shift",
"control",
"option",
"command",
"numericpad",
"help",
"function"
],
"16711680": [
"alphashift",
"shift",
"control",
"option",
"command",
"numericpad",
"help",
"function"
],
"16777216": []
}
(() => {
const NX_ALPHASHIFTMASK = '00010000';
const NX_SHIFTMASK = '00020000';
const NX_CONTROLMASK = '00040000';
const NX_ALTERNATEMASK = '00080000';
const NX_COMMANDMASK = '00100000';
const NX_NUMERICPADMASK = '00200000';
const NX_HELPMASK = '00400000';
const NX_SECONDARYFNMASK = '00800000';
const NX_ALPHASHIFT_STATELESS_MASK = '1000000';
const MODIFIERS = {
alphashift: NX_ALPHASHIFTMASK,
shift: NX_SHIFTMASK,
control: NX_CONTROLMASK,
option: NX_ALTERNATEMASK,
command: NX_COMMANDMASK,
numericpad: NX_NUMERICPADMASK,
help: NX_HELPMASK,
function: NX_SECONDARYFNMASK,
};
// i'm 100% sure there's a better way to do this, but i'm not that smart
function pairPrefix(prefixes, keys) {
return prefixes.flatMap((prefix, i) => {
const res = keys.slice(i + 1).map((key) => [...prefix, key]);
return [...res, ...pairPrefix(res, keys.slice(i + 1))];
});
}
return {
[parseInt(NX_ALPHASHIFT_STATELESS_MASK, 16)]: [],
...[
...Object.keys(MODIFIERS).map((key) => [key]),
...pairPrefix(
Object.keys(MODIFIERS).map((key) => [key]),
Object.keys(MODIFIERS),
),
].reduce(
(map, keys) =>
Object.assign(map, {
[keys.reduce((acc, cur) => acc | parseInt(MODIFIERS[cur], 16), 0)]:
keys,
}),
{},
),
};
})();
@stephancasas
Copy link
Author

stephancasas commented Nov 28, 2022

These are the keymask values used in com.apple.symbolichotkeys.plist. I seriously doubt that the NX_HELPMASK and NX_ALPHASHIFTMASK apply on today's keymaps, but it was in the header file, so I included it anyway.

It's worth noting that, when testing, 10485760 is the keymask value that my system produced for arrow_down even though no other keys were being held. If you're using these values for AX scripting, you may wish to watch-out for those types of exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment