Skip to content

Commit 7615776

Browse files
committed
2.5: v-on modifiers
1 parent db62039 commit 7615776

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/v2/guide/events.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,21 @@ You can also [define custom key modifier aliases](../api/#keyCodes) via the glob
243243
Vue.config.keyCodes.f1 = 112
244244
```
245245

246-
## Modifier Keys
246+
### Automatic Key Modifers
247+
248+
> New in 2.5.0+
249+
250+
You can also 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:
251+
252+
``` html
253+
<input @keyup.page-down="onPageDown">
254+
```
255+
256+
In the above example, the handler will only be called if `$event.key === 'PageDown'`.
257+
258+
<p class="tip">A few keys (`.esc` and all arrow keys) have inconsistent `key` values in IE9, their built-in aliases should be preferred if you need to support IE9.</p>
259+
260+
## System Modifier Keys
247261

248262
> New in 2.1.0
249263
@@ -268,6 +282,20 @@ For example:
268282

269283
<p class="tip">Note that modifier keys are different from regular keys and when used with `keyup` events, they have to be pressed when the event is emitted. In other words, `keyup.ctrl` will only trigger if you release a key while holding down `ctrl`. It won't trigger if you release the `ctrl` key alone.</p>
270284

285+
### `.exact` Modifier
286+
287+
> New in 2.5.0
288+
289+
The `.exact` modifier should be used in combination with other system modifiers to indicate that the exact combination of modifiers must be pressed for the handler to fire.
290+
291+
``` html
292+
<!-- this will fire even if Alt or Shift is also pressed -->
293+
<button @click.ctrl="onClick">A</button>
294+
295+
<!-- this will only fire when only Ctrl is pressed -->
296+
<button @click.ctrl.exact="onCtrlClick">A</button>
297+
```
298+
271299
### Mouse Button Modifiers
272300

273301
> New in 2.2.0+

0 commit comments

Comments
 (0)