...

/

Mouse and Keyboard Events

Mouse and Keyboard Events

Learn about mouse clicks and keyboard events in Vue.js.

In this lesson, learn how to make the Vue.js application interactive by handling mouse and keyboard events. Mouse and keyboard events can be bound to the methods and data so the application does an operation when an element is clicked or a key is pressed. All the mouse and keyboard event handlers are bound to the methods and data using the v-on directive.

v-on:click

The mouse click event is one of the most used events on webpages when surfing the internet. When users click on a button or any other HTML element, they expect it to do something. This means that the click event performs action. That action might involve interaction with the data. The Vue.js click event is similar to the onclick event in vanilla JavaScript but it provides additional functionality.

svg viewer

The following is an executable example demonstrating the use of the v-on ...