Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onkeydown doesn't work #526

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

onkeydown doesn't work #526

rudinandrey opened this issue Mar 21, 2015 · 6 comments

Comments

@rudinandrey
Copy link

@rudinandrey rudinandrey commented Mar 21, 2015

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
Copy link
Contributor

@rsbondi rsbondi commented Mar 22, 2015

return true after the update, not sure why,

Loading

@cognitom
Copy link
Member

@cognitom cognitom commented Mar 22, 2015

@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.

Loading

@rsbondi
Copy link
Contributor

@rsbondi rsbondi commented Mar 22, 2015

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

Loading

@GianlucaGuarini
Copy link
Member

@GianlucaGuarini GianlucaGuarini commented Mar 22, 2015

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.

Loading

@cognitom
Copy link
Member

@cognitom cognitom commented Mar 22, 2015

@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.

Loading

@rudinandrey
Copy link
Author

@rudinandrey rudinandrey commented Mar 22, 2015

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

Loading

@GianlucaGuarini GianlucaGuarini mentioned this issue May 9, 2016
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants