react-keyboard
  • Introduction
  • Event Propagation
  • Navigation
Powered by GitBook
On this page

Was this helpful?

Event Propagation

In the example of introduction, when press command+k when focus is on child, you will see the handlers of both child and parent are called. Use e.stopPropagation to avoid event propagation from child.

  showChildDocumentation = (e: KeyboardEvent) => {
    console.log('show child doc')
    e.stopPropagation()
  }

Or simply return false

  showChildDocumentation = () => {
    console.log('show child doc')
    return false
  }

this is the same as e.stopPropagation() + e.preventDefault()

PreviousIntroductionNextNavigation

Last updated 6 years ago

Was this helpful?