简体   繁体   中英

React Keyboard event listener on window

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?

只要您不在外部操作Dom react渲染,就可以在窗口上附加事件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM