What's the most idiomatic way of listening/handling global DOM events in ReasonML.
I'm building a ReasonReact version of the 2048 game where I need to listen for keyboard events.
In a standard JS/React app I'd have a component with a componentDidMount
lifecycle method where I would listen to the event with document.addEventListener("keypress", [my_event_handler])
and unlisten to the same on componentWillUnmount
with document.removeEventListener("keypress", [my_event_handler])
.
What's the most idiomatic way of accessing document.(addEventListener/removeEventListener) in Reason/ReasonReact?
event.key
, but I can't. How am I to understand that file? – Aubervilliers