我正在尝试实现一些非常基本的按键检测,但我根本无法让它工作。我有一个应该接收onKeyDown
事件的裸组件,但控制台中没有任何内容被注销:
class App extends React.Component {
constructor(props) {
super(props);
}
handleKeyDown(event) {
console.log('handling a key press');
}
render() {
return (
<ChildComponent onKeyDown={this.handleKeyDown} />
);
}
}
React.render(<App />, document.getElementById('app'));