What would be the best way to detect onkeypress
event on a div in backbonejs view?
Currently putting it in the events is not working,
events: {
"keypress div#xyz": "myFunction"
}
The problem is that keyboard events are sent only to the element that has focus (for example a form input) and are not bubbled to container elements. http://api.jquery.com/keyup/
You should bind it to the exact element(s) in which text can be entered.
events: { "keypress #xyz input" : "myFunction" }