Skip to main content
Question

Is there a way to trigger shortcuts via the API?


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

Thank you Tank!!


Lewis_Healey
  • Author
  • New Participant
  • 14 replies
  • 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
  • 4708 replies
  • 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
  • 14 replies
  • January 26, 2024

Ahhh thank you very much Gleb


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings