window.addEventListener / document.addEventListener are not working

Hi!

I need to add global events to identify if user pressed the "Enter" key on keyboard.
I've tried to add window.addEventListener('key...) logic but it doesn't work.
I also tried to use something like that: document.body.onkeydown or window.onkeydown - the same.

hi, welcome to the community

Retool runs all your javascript code in a sandboxed environment that doesn't have access to the parent Window or document. You can read more about that here:

What you may want to do is investigate a custom component or imported js module

2 Likes