Skip to main content
Question

Is there a way to trigger shortcuts via the API?

  • January 24, 2024
  • 5 replies
  • 399 views

Lewis_Healey

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
  • January 24, 2024

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.


Lewis_Healey
  • Author
  • New Participant
  • January 24, 2024

Thank you Tank!!


Lewis_Healey
  • Author
  • New Participant
  • January 25, 2024

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
  • January 25, 2024

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


Lewis_Healey
  • Author
  • New Participant
  • January 26, 2024

Ahhh thank you very much Gleb