Pick a value from an event
const MyComponent = () => { const key = useEvent({ eventName: "keydown", getValue: event => event.key, initialState: "" }); return <div>Last used key was {key}</div>;} Copy
const MyComponent = () => { const key = useEvent({ eventName: "keydown", getValue: event => event.key, initialState: "" }); return <div>Last used key was {key}</div>;}
name of the event
function that receives the event and should return the value you are interested in
initial state or function that returns initial state
Optional
event target, defaults to window
Generated using TypeDoc
Pick a value from an event
Example