Div supports event attributes, according to w3schools: http://www.w3schools.com/tags/tag_div.asp . I am not one hundred percent sure how it works exactly but I would assume it would work exactly like using it on input.
@maxnb
It's due to an error in @tykus's answer. The addEventListener method takes a function as a second argument, not it's result. Simply remove the parentheses:
new Vue({
created: function () {
window.addEventListener('keyup', this.myMethod)
},
methods: {
myMethod: function () {
// stuff
}
}
...
});
div is not focusable element by default, you can make it focusable by tabindex attribute set it to 0. Once you make it focusable, you can focus on div element. And, when you have focus on element, all key events will be triggered.