Skip to main content
Solved

Unable to create Trigger with type 'ON_KEY_DOWN'

  • September 6, 2021
  • 2 replies
  • 688 views

aashreys

Hey folks I’m trying to create a Reaction with a keyboard keypress Trigger in my plugin:

  let reaction = {
    action: nodeAction,
    trigger: {
      type: 'ON_KEY_DOWN',
      device: 'KEYBOARD',
      keyCodes: [83]
    }
  };

But I get the following build error when I use the above code:

Type '"ON_KEY_DOWN"' is not assignable to type '"ON_CLICK" | "ON_HOVER" | "ON_PRESS" | "ON_DRAG" | "AFTER_TIMEOUT" | "MOUSE_ENTER" | "MOUSE_LEAVE" | "MOUSE_UP" | "MOUSE_DOWN"'.

ON_KEY_DOWN is defined as a valid Trigger type in the docs but the plugin API doesn’t reflect that. Any idea how I can get this working?

Best answer by aashreys

Hey Gleb turns out I was running an outdated version of typings. Updating it resolved the issue. 🙂

View original

2 replies

Gleb
  • Power Member
  • 4708 replies
  • September 6, 2021

Does it work from the console or without TypeScript, if you just write the JS code? If it does, it might be an error in the typings file which can be reported by opening an issue here: https://github.com/figma/plugin-typings


aashreys
  • Author
  • 5 replies
  • Answer
  • September 13, 2021

Hey Gleb turns out I was running an outdated version of typings. Updating it resolved the issue. 🙂


Reply


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