CHAPTER 09
Beginner
Event Handling in Vue.js
Updated: May 18, 2026
5 min read
# CHAPTER 9
Event Handling in Vue.js
1. Chapter Introduction
Events are how users interact with your app — clicks, key presses, form submissions, scroll, and drag. Vue'sv-on directive (shorthand @) binds event listeners with optional modifiers that eliminate boilerplate code like event.preventDefault().
2. Learning Objectives
- Handle click, input, keyboard, and mouse events.
- Use event modifiers for common patterns.
- Use keyboard key modifiers.
- Access the native event object.
- Build an interactive todo application.
3. Basic Event Handling
vue
4. Event Modifiers
vue
5. Keyboard Event Modifiers
vue
6. Mouse Event Modifiers
vue
7. Mini Project: Interactive Todo App
vue
8. Common Mistakes
-
Not using
.preventon form submit: Without it, form submission reloads the page, losing all Vue state.
-
Using
@click="method()"vs@click="method": Both work, but@click="method"passes the event automatically.@click="method()"does NOT pass the event unless you write@click="method($event)".
9. MCQs
Question 1
What does @submit.prevent do?
Question 2
@click.stop does?
Question 3
@keyup.enter fires when?
Question 4
@click.once fires?
Question 5
@click.self fires when?
Question 6
How do you access native event in inline handler?
Question 7
@click.ctrl.exact fires when?
Question 8
@keyup.escape fires on?
Question 9
.passive modifier is best for?
Question 10
Ctrl+Enter keyboard shortcut?
10. Interview Questions
-
Q: What is the difference between
@click="handler"and@click="handler()"?
-
Q: When would you use the
.passiveevent modifier?
11. Summary
Vue's event system with@event syntax and modifiers like .prevent, .stop, .once, and .self replaces dozens of lines of DOM event code. Key and mouse modifiers make keyboard shortcuts and right-click menus trivial. The todo app demonstrates how events, reactivity, and computed properties combine into a fully functional UI.
12. Next Chapter Recommendation
In Chapter 10: Conditional Rendering and Lists, we masterv-if, v-else, v-for with performance optimization, and build a complete product listing application.