Skip to content

Commit 4cc79e1

Browse files
eostromeddyerburgh
authored andcommitted
docs: update key event example (vuejs#1165)
1 parent 124a6e7 commit 4cc79e1

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

docs/guides/dom-events.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ This component allows to increment/decrement the quantity using various keys.
101101
const KEY_DOWN = 40
102102
const KEY_UP = 38
103103
const ESCAPE = 27
104-
const CHAR_A = 65
105104
106105
export default {
107106
data() {
@@ -130,7 +129,7 @@ This component allows to increment/decrement the quantity using various keys.
130129
if (e.keyCode === KEY_UP) {
131130
this.increment()
132131
}
133-
if (e.which === CHAR_A) {
132+
if (e.key === 'a') {
134133
this.quantity = 13
135134
}
136135
}
@@ -180,7 +179,7 @@ describe('Key event tests', () => {
180179
it('Magic character "a" sets quantity to 13', () => {
181180
const wrapper = mount(QuantityComponent)
182181
wrapper.trigger('keydown', {
183-
which: 65
182+
key: 'a'
184183
})
185184
expect(wrapper.vm.quantity).toBe(13)
186185
})

docs/ja/guides/dom-events.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ describe('Click event', () => {
9797
const KEY_DOWN = 40
9898
const KEY_UP = 38
9999
const ESCAPE = 27
100-
const CHAR_A = 65
101100
102101
export default {
103102
data() {
@@ -125,7 +124,7 @@ describe('Click event', () => {
125124
if (e.keyCode === KEY_UP) {
126125
this.increment()
127126
}
128-
if (e.which === CHAR_A) {
127+
if (e.key === 'a') {
129128
this.quantity = 13
130129
}
131130
}
@@ -174,7 +173,7 @@ describe('Key event tests', () => {
174173
it('Magic character "a" sets quantity to 13', () => {
175174
const wrapper = mount(QuantityComponent)
176175
wrapper.trigger('keydown', {
177-
which: 65
176+
key: 'a'
178177
})
179178
expect(wrapper.vm.quantity).toBe(13)
180179
})

docs/ru/guides/dom-events.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ describe('Click event', () => {
9797
const KEY_DOWN = 40
9898
const KEY_UP = 38
9999
const ESCAPE = 27
100-
const CHAR_A = 65
101100
102101
export default {
103102
data() {
@@ -125,7 +124,7 @@ describe('Click event', () => {
125124
if (e.keyCode === KEY_UP) {
126125
this.increment()
127126
}
128-
if (e.which === CHAR_A) {
127+
if (e.key === 'a') {
129128
this.quantity = 13
130129
}
131130
}
@@ -174,7 +173,7 @@ describe('Тестирование событий клавиш', () => {
174173
it('Магический символ "a" устанавливает quantity равным 13', () => {
175174
const wrapper = mount(QuantityComponent)
176175
wrapper.trigger('keydown', {
177-
which: 65
176+
key: 'a'
178177
})
179178
expect(wrapper.vm.quantity).toBe(13)
180179
})

docs/zh/guides/dom-events.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ describe('点击事件', () => {
101101
const KEY_DOWN = 40
102102
const KEY_UP = 38
103103
const ESCAPE = 27
104-
const CHAR_A = 65
105104
106105
export default {
107106
data() {
@@ -130,7 +129,7 @@ describe('点击事件', () => {
130129
if (e.keyCode === KEY_UP) {
131130
this.increment()
132131
}
133-
if (e.which === CHAR_A) {
132+
if (e.key === 'a') {
134133
this.quantity = 13
135134
}
136135
}
@@ -180,7 +179,7 @@ describe('键盘事件测试', () => {
180179
it('魔术字符 "a" 键将数量设置为 13', () => {
181180
const wrapper = mount(QuantityComponent)
182181
wrapper.trigger('keydown', {
183-
which: 65
182+
key: 'a'
184183
})
185184
expect(wrapper.vm.quantity).toBe(13)
186185
})

0 commit comments

Comments
 (0)