Reputation: 159
What is the best way to attach an event listener on a div/window that listens for keypress in React. I know the synthetic keyboard events that you can attach to form fields, like onKeyDown etc. Is there any down falls to attaching just vanilla JS eventListeners on window in ComponentDidMount?
Upvotes: 0
Views: 472
Reputation: 6803
As long as you dont manipulate the Dom outside react render it is safe to attach events on window
Upvotes: 1