Direkt aus der Post von Oscar ...
property vers : "1.0"
my isModifierKeyPressed("function") // the only addition to his raw script
on isModifierKeyPressed(checkKey)
set modiferKeysDOWN to {command_down:false, option_down:false, control_down:false, shift_down:false, caps_down:false, numlock_down:false, function_down:false}
if checkKey = "" or checkKey = "option" or checkKey = "alt" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSAlternateKeyMask '") > 1 then
set option_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "command" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSCommandKeyMask '") > 1 then
set command_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "shift" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSShiftKeyMask '") > 1 then
set shift_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "control" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSControlKeyMask '") > 1 then
set control_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "caps" or checkKey = "capslock" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSAlphaShiftKeyMask '") > 1 then
set caps_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "numlock" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSNumericPadKeyMask'") > 1 then
set numlock_down of modiferKeysDOWN to true
end if
end if
--Set if any key in the numeric keypad is pressed. The numeric keypad is generally on the right side of the keyboard. This is also set if any of the arrow keys are pressed
if checkKey = "" or checkKey = "function" or checkKey = "func" or checkKey = "fn" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSFunctionKeyMask'") > 1 then
set function_down of modiferKeysDOWN to true
end if
end if
--Set 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)
return modiferKeysDOWN
end isModifierKeyPressed
wenn Fn unten ist
Result:
{command_down:false, option_down:false, control_down:false, shift_down:false, caps_down:false, numlock_down:false, function_down:true}
sonst
Result:
{command_down:false, option_down:false, control_down:false, shift_down:false, caps_down:false, numlock_down:false, function_down:false}