Add a listener for a keydown event on a specific key.
const MyComponent = () => { useKeyCallback("Escape", () => window.close()); return <div>Press escape to close window</div>} Copy
const MyComponent = () => { useKeyCallback("Escape", () => window.close()); return <div>Press escape to close window</div>}
the specific key you want to listen to
the function that will be called when the key has been pressed. Receives the keydown event
Optional
flag to indicate if the listener should be active right now
Generated using TypeDoc
Add a listener for a keydown event on a specific key.
Example