I want to capture keydown events from children. Is this possible? So say I have
onKeyDown = e => {
e.stopPropagation();
console.log("Hello world from Parent!");
return false;
}
<ParentComponent onKeyDown={this.onKeyDown}>
<div tabIndex='0' id='child'>Focus on me and press a button!</div>
</ParentComponent>
I want to print "Hello World" when you press a button while focused on the div child.
I've tried it and doesn't seem to be working, and reading another SO thread it seems to work with click handlers as long as e.stopPropagation()
is used. How come it doesn't work with keydown events?