Skip to content

Commit d9ae979

Browse files
authored
Remove keyCode support in v-on (#95)
* drop keycode support RFC * Rename 0000-drop-keycode-support.md to 0014-drop-keycode-support.md
1 parent ea9b219 commit d9ae979

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
- Start Date: 2019-11-08
2+
- Target Major Version: 3.x
3+
- Reference Issues: N/A
4+
- Implementation PR: N/A
5+
6+
# Summary
7+
8+
- Drop support for using numbers (keyCodes) as `v-on` modifiers
9+
- Remove `config.keyCodes`
10+
11+
# Basic example
12+
13+
N/A
14+
15+
# Motivation
16+
17+
In Vue 2.x, `v-on` already supports using the kebab-case version of any valid `KeyboardEvent.key` as a modifier. For example, to trigger the handler only when `event.key === 'PageDown'`:
18+
19+
``` html
20+
<input @keyup.page-down="onArrowUp">
21+
```
22+
23+
This makes number keyCodes and `config.keyCodes` redundant. In addition, [`KeyboardEvent.keyCode` has been deprecated](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode), so it would make sense for Vue to stop supporting it as well.
24+
25+
# Drawbacks
26+
27+
N/A
28+
29+
# Alternatives
30+
31+
N/A
32+
33+
# Adoption strategy
34+
35+
- A codemod can detect usage of number `keyCode` modifier usage and convert it to `key` equivalents.
36+
37+
- In compat build, `config.keyCode` can be supported, and the runtime can emit warning when a keyCode alias is matched to allow easy migration.

0 commit comments

Comments
 (0)