javascript / beginner
Snippet
Keyboard Events: .enter Modifier
Vue provides modifiers for keyboard events that allow you to listen for specific keys. The .enter modifier ensures the function only runs when the Enter key is released.
snippet.js
1
<input @keyup.enter="addItem" placeholder="Press Enter" />
vue
Breakdown
1
@keyup.enter
A modifier that triggers the event listener only for the Enter key.
2
addItem
The logic that will be called to process the keyboard input.