Is there a way to trigger shortcuts via the API?

I would love to be able to trigger cmd + . or “N” via the plugin I’m building, is this possible?

Please read the documentation:

And note that for shortcuts to be processed by your plugin’s iframe, it must be in focus.

Thank you Tank!!

Hey Tank, is there anything particular I need to do to focus the plugin? I was getting KeyboardEvent is not a constructor

from var event = new KeyboardEvent("keydown", { key: "Enter", code: "Enter", keyCode: 13, ctrlKey: true, shiftKey: false, altKey: false, metaKey: false, bubbles: true, cancelable: true, }); document.dispatchEvent(event);

Appreciate any guidance on this

You can’t trigger Figma shortcuts from a plugin. The link above is useful for catching keypresses within the plugin UI.

Ahhh thank you very much Gleb