Running scripts with different key combos for different behaviour

Hello,

I’d like to request a feature.

In the good old days, the scripts by Adobe for FontLab, allowed the script behaviour to be changed by holding particular keys. Holding the ctrl key, ran the script without the UI for instance.

I understand this may not be possible. I also wouldn’t want it to become a Tekken kill key combo either.

Cheers,
Marc

You can use a key mask.

from AppKit import NSCommandKeyMask
cmdPressed = bool(NSEvent.modifierFlags() & NSCommandKeyMask)
if cmdPressed:
	print "Gotcha. You are holding down your CMD key!"

Key masks include:

NSAlphaShiftKeyMask
NSAlternateKeyMask
NSCommandKeyMask
NSControlKeyMask
NSFunctionKeyMask
NSHelpKeyMask
NSNumericPadKeyMask
NSShiftKeyMask

EDIT: More info on https://developer.apple.com/reference/appkit/nseventmodifierflags where I just read that this is going to be deprecated. But the sample above still works.

or you use several scripts that all call the same code and give each its own key command.

They just changed the names of the constants. The mechanisms is the same.

Thank you two :-). Very helpful.