How to listen for whether the option key is pressed in the right-click menu?

Detect Option key in general or inside a menu?

Ah, sorry. The detection works fine, using NSEventModifierFlagOption. In my example, I can have an action apply across all masters when Option is pressed.

However, I can’t get the context menu item to read “… in all Masters”.

For “in all Masters” items, add a second menu item directly after the first, give it a keyEquivalentModifierMask of NSEventModifierFlagOption and set alternate to True.

Hmm. I tried this:

contextMenus.append(
	{
		"name": Glyphs.localize({"en": "Do stuff"}),
		"action": self.doStuff_
	}
)

contextMenus.append(
	{
		"name": Glyphs.localize({
			"en": "Do stuff in all Masters",
		}),
		"action": self.doStuff_,
		"keyEquivalentModifierMask": NSEventModifierFlagOption,
		"alternate": True,
	}
)

But now I just get two menu items all the time, they don’t toggle between one another.

You need to build the context menu directly using NSMenuItem …

The simple API doesn’t support alternate items, yet.