You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/v2/guide/events.md
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -226,14 +226,18 @@ The `.passive` modifier is especially useful for improving performance on mobile
226
226
When listening for keyboard events, we often need to check for specific keys. Vue allows adding key modifiers for `v-on` when listening for key events:
227
227
228
228
```html
229
-
<!-- only call `vm.submit()` when the `key` is PageDown-->
230
-
<input@keyup.page-down="onPageDown">
229
+
<!-- only call `vm.submit()` when the `key` is `Enter`-->
230
+
<inputv-on:keyup.enter="submit">
231
231
```
232
232
233
-
In the above example, the handler will only be called if `$event.key` is equal to `'PageDown'`.
234
-
235
233
You can directly use any valid key names exposed via [`KeyboardEvent.key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) as modifiers by converting them to kebab-case.
236
234
235
+
```html
236
+
<inputv-on:keyup.page-down="onPageDown">
237
+
```
238
+
239
+
In the above example, the handler will only be called if `$event.key` is equal to `'PageDown'`.
240
+
237
241
### Key Codes
238
242
239
243
<pclass="tip">The use of `keyCode` events [is deprecated](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode) and may not be supported in new browsers.</p>
0 commit comments