Skip to content

Commit f7d47e2

Browse files
committed
tests: Add avm2/key_input_location test
This test verifies the behavior of keyLocation in key events.
1 parent ec58ef1 commit f7d47e2

File tree

5 files changed

+181
-0
lines changed

5 files changed

+181
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package {
2+
import flash.display.*;
3+
import flash.text.*;
4+
import flash.text.engine.*;
5+
import flash.events.*;
6+
import flash.geom.*;
7+
import flash.utils.getTimer;
8+
9+
[SWF(frameRate="25")]
10+
public class Test extends MovieClip {
11+
public function Test() {
12+
stage.addEventListener("keyDown", function(evt: KeyboardEvent): void {
13+
trace("Key down:");
14+
printKey(evt);
15+
});
16+
stage.addEventListener("keyUp", function(evt: KeyboardEvent): void {
17+
trace("Key up:");
18+
printKey(evt);
19+
});
20+
}
21+
22+
private function printKey(evt: KeyboardEvent): void {
23+
trace(" altKey: " + evt.altKey);
24+
trace(" charCode: " + evt.charCode);
25+
trace(" ctrlKey: " + evt.ctrlKey);
26+
trace(" keyCode: " + evt.keyCode);
27+
trace(" keyLocation: " + evt.keyLocation);
28+
trace(" shiftKey: " + evt.shiftKey);
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{ "type": "KeyDown", "key": { "Char": "a" } },
3+
{ "type": "KeyUp", "key": { "Char": "a" } },
4+
{ "type": "KeyDown", "key": "LeftShift" },
5+
{ "type": "KeyUp", "key": "LeftShift" },
6+
{ "type": "KeyDown", "key": "RightShift" },
7+
{ "type": "KeyUp", "key": "RightShift" },
8+
{ "type": "KeyDown", "key": "LeftControl" },
9+
{ "type": "KeyUp", "key": "LeftControl" },
10+
{ "type": "KeyDown", "key": "RightControl" },
11+
{ "type": "KeyUp", "key": "RightControl" },
12+
{ "type": "KeyDown", "key": "LeftAlt" },
13+
{ "type": "KeyUp", "key": "LeftAlt" },
14+
15+
{ "type": "KeyDown", "key": { "Numpad": "1" } },
16+
{ "type": "KeyUp", "key": { "Numpad": "1" } },
17+
{ "type": "KeyDown", "key": "NumLock" },
18+
{ "type": "KeyUp", "key": "NumLock" },
19+
{ "type": "KeyDown", "key": "NumpadEnd" },
20+
{ "type": "KeyUp", "key": "NumpadEnd" },
21+
22+
{ "type": "Wait" }
23+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
Key down:
2+
altKey: false
3+
charCode: 97
4+
ctrlKey: false
5+
keyCode: 65
6+
keyLocation: 0
7+
shiftKey: false
8+
Key up:
9+
altKey: false
10+
charCode: 97
11+
ctrlKey: false
12+
keyCode: 65
13+
keyLocation: 0
14+
shiftKey: false
15+
Key down:
16+
altKey: false
17+
charCode: 0
18+
ctrlKey: false
19+
keyCode: 16
20+
keyLocation: 1
21+
shiftKey: true
22+
Key up:
23+
altKey: false
24+
charCode: 0
25+
ctrlKey: false
26+
keyCode: 16
27+
keyLocation: 1
28+
shiftKey: false
29+
Key down:
30+
altKey: false
31+
charCode: 0
32+
ctrlKey: false
33+
keyCode: 16
34+
keyLocation: 2
35+
shiftKey: true
36+
Key up:
37+
altKey: false
38+
charCode: 0
39+
ctrlKey: false
40+
keyCode: 16
41+
keyLocation: 2
42+
shiftKey: false
43+
Key down:
44+
altKey: false
45+
charCode: 0
46+
ctrlKey: true
47+
keyCode: 17
48+
keyLocation: 1
49+
shiftKey: false
50+
Key up:
51+
altKey: false
52+
charCode: 0
53+
ctrlKey: false
54+
keyCode: 17
55+
keyLocation: 1
56+
shiftKey: false
57+
Key down:
58+
altKey: false
59+
charCode: 0
60+
ctrlKey: true
61+
keyCode: 17
62+
keyLocation: 2
63+
shiftKey: false
64+
Key up:
65+
altKey: false
66+
charCode: 0
67+
ctrlKey: false
68+
keyCode: 17
69+
keyLocation: 2
70+
shiftKey: false
71+
Key down:
72+
altKey: true
73+
charCode: 0
74+
ctrlKey: false
75+
keyCode: 18
76+
keyLocation: 1
77+
shiftKey: false
78+
Key up:
79+
altKey: false
80+
charCode: 0
81+
ctrlKey: false
82+
keyCode: 18
83+
keyLocation: 1
84+
shiftKey: false
85+
Key down:
86+
altKey: false
87+
charCode: 49
88+
ctrlKey: false
89+
keyCode: 97
90+
keyLocation: 3
91+
shiftKey: false
92+
Key up:
93+
altKey: false
94+
charCode: 49
95+
ctrlKey: false
96+
keyCode: 97
97+
keyLocation: 3
98+
shiftKey: false
99+
Key down:
100+
altKey: false
101+
charCode: 0
102+
ctrlKey: false
103+
keyCode: 144
104+
keyLocation: 0
105+
shiftKey: false
106+
Key up:
107+
altKey: false
108+
charCode: 0
109+
ctrlKey: false
110+
keyCode: 144
111+
keyLocation: 0
112+
shiftKey: false
113+
Key down:
114+
altKey: false
115+
charCode: 0
116+
ctrlKey: false
117+
keyCode: 35
118+
keyLocation: 3
119+
shiftKey: false
120+
Key up:
121+
altKey: false
122+
charCode: 0
123+
ctrlKey: false
124+
keyCode: 35
125+
keyLocation: 3
126+
shiftKey: false
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
num_ticks = 1

0 commit comments

Comments
 (0)