Skip to main content
Lewis_Healey
New Participant
Jan 24, 2024 11:23 AM UTC
Question

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?

This topic has been closed for replies.

5 replies

tank666
Jan 24, 2024 11:53 AM UTC

Please read the documentation:

MDN Web Docs

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

UX/UI designer. Figma expert. Creator and developer of plugins and widgets for Figma and FigJam. Check out my resources in Figma Community: figma.com/@tank
Lewis_Healey
New Participant
Jan 24, 2024 8:53 PM UTC

Thank you Tank!!

Lewis_Healey
New Participant
Jan 25, 2024 6:59 AM UTC

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

Gleb
Power Member
Jan 25, 2024 7:21 AM UTC

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

Lewis_Healey
New Participant
Jan 26, 2024 2:07 AM UTC

Ahhh thank you very much Gleb