onkeydown doesn't work #526

Closed
rudinandrey opened this Issue Mar 21, 2015 · 6 comments

Projects

None yet

4 participants

@rudinandrey

http://jsfiddle.net/rudinandrey/6uwdyzs1/

that is code... when I press button inside input text I will have nothing to input ( but event is work, i get keyCodes . What is wrong ?

@rsbondi
Contributor
rsbondi commented Mar 22, 2015

return true after the update, not sure why,

@cognitom
Member

@rudinandrey .bind(this) is needed.
http://jsfiddle.net/cognitom/j2p8vu4s/

Or ES6 method is also OK: press (e) { ... }
http://jsfiddle.net/cognitom/32xbcc9p/

See Custom tag example.

@rsbondi
Contributor
rsbondi commented Mar 22, 2015

@cognitom neither of those work for me, the input is always empty.

@GianlucaGuarini
Member

Please check the riot documentation https://muut.com/riotjs/guide/#event-handlers

The default event handler behavior is automatically cancelled. This means that e.preventDefault() is already called for you, because this is what you usually want (or forget to do). You can let the browser do the default thing by returning true on the handler.

@cognitom
Member

@rsbondi sorry, you're right. I misread the question.
I've slightly updated my jsFiddle to work fine by adding an attribute value={ name } to the tag. It's another solution.

But I agree that return false is suitable in this situation.

@rudinandrey

@GianlucaGuarini thank you. This is very useful comment for me.

This was referenced Mar 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment