0

enter image description here

in my separated js file:

function yell(e) {

    console.log("yell() ", JSON.stringify(e.value));

    console.log("yell() keycode ", e.keyCode, e.key);

    if (e.key === 'Enter' || e.keyCode === 13) {

        // Do something

    }

}

I would like to detect Enter is hit, but the e.key and e.keyCode do not have any value. e.value has the value of textbox which I also need.

So how can I detect user hits Enter?

Franva
  • 6,565
  • 23
  • 79
  • 144
  • It seems like `this` is not what you're expecting, and that probably has something to do with the way you're going from Markdown to JSX/React elements, but you haven't provided any details on how that's been implemented. – coreyward Aug 24 '20 at 17:03
  • @coreyward I don't have anything in React element, simply because that Netlify CMS seems using a generic HtmlContent which is a Content reactjs component which is used for all pages, the content of the Content is extracted from about/index.md. So I am kinda lost in this approach and have no idea how to add React event only for About page on the generic Content component. So I put the yell() code in a completely separated helpers.js file which has nothing but this one method. So you are not missing anything here. In short, the html textbox from Markdown and the JS code from a helpers.js file. – Franva Aug 24 '20 at 22:59

0 Answers0