If you log it to the console like this, Chrome (at least) will print it interactively and update it if something changes. React uses a pool of event objects and invalidates (= resets everything to null) as soon as the handler is done.
This is also problematic when putting events into a core.async channel etc. Your comparison should work though. As a workaround for the printing, use `cljs.core/println' and/or just print the stuff you need. Andrew S <[email protected]> writes: > I seem to be having the same problem as this guy: > > http://stackoverflow.com/questions/22123055/react-keyboard-event-handlers-all-null > > I need some assistance how to translate this answer into clojurescript. I > have an Om component (a dom/input) with this handler: > > :onKeyPress #(.log js/console % "pressed: " (.-keyCode %)) > > The event itself is logged and everything is null when I type an Esc key, > Enter key, etc. It's not clear to me how to access this synthesized > information using CLJS syntax, can anyone assist? > > Before logging, I tried to actually do something like this: > > (when (== (.-keyCode %) 27) ;escape key .... > > But since the keyCode value is always 0, that didn't work. > > Andrew > > -- > Note that posts from new members are moderated - please be patient with your > first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript. -- -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
signature.asc
Description: PGP signature
