/
index.html
87 lines (74 loc) · 2.72 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<meta charset=utf-8>
<link href="peanutbutter.css" rel="stylesheet">
<body>
<h1>Peanut Butter</h1>
<p>For testing mousetrap</p>
<p>When the row is highlighted press the key(s). If you can't get anything to happen for a certain test press the f key to mark it as a failure</p>
<table>
<thead>
<tr>
<th>keys</th>
<th>keypress</th>
<th>keydown</th>
<th>keyup</th>
<th>result</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script src="jquery-1.7.2.min.js"></script>
<script src="../mousetrap.js"></script>
<script src="peanutbutter.js"></script>
<script>
/**
* SINGLE KEYS
*/
PeanutButter.addTest('a', ['keypress']);
PeanutButter.addTest('A', ['keypress']);
PeanutButter.addTest('*', ['keypress']);
PeanutButter.addTest('?', ['keypress']);
// this works with keypress
// PeanutButter.addTest('', ['keypress']);
PeanutButter.addTest('a', ['keydown', 'keyup']);
PeanutButter.addTest(',', ['keydown', 'keyup']);
PeanutButter.addTest('7', ['keydown', 'keyup']);
PeanutButter.addTest('enter', ['keydown', 'keyup']);
PeanutButter.addTest('*', ['keydown', 'keyup']);
PeanutButter.addTest('?', ['keydown', 'keyup']);
PeanutButter.addTest('f1', ['keydown', 'keyup']);
/*
* COMBINATIONS
*/
// for whatever reason command key combos don't work with keyup
PeanutButter.addTest('command+a', ['keydown']);
PeanutButter.addTest('command+shift+k', ['keydown']);
PeanutButter.addTest('shift+a', ['keydown', 'keyup']);
PeanutButter.addTest('option+a', ['keydown', 'keyup']);
PeanutButter.addTest('ctrl+shift+up', ['keydown', 'keyup']);
/**
* SEQUENCES
*/
// sequences need to be one or the other, so they
// can't happen in the same test
PeanutButter.addTest('* a', ['keypress']);
PeanutButter.addTest('* a', ['keydown']);
// key up with a modifier key is hard but possible
PeanutButter.addTest('* a', ['keyup']);
PeanutButter.addTest('k e y s', ['keypress']);
PeanutButter.addTest('k e y s', ['keydown']);
PeanutButter.addTest('k e y s', ['keyup']);
PeanutButter.addTest('left right left right', ['keydown']);
PeanutButter.addTest('left right left right', ['keyup']);
// sequence with modifier
PeanutButter.addTest('k command+u', ['keydown']);
PeanutButter.addTest('g .', ['keydown']);
PeanutButter.addTest('. g', ['keydown']);
PeanutButter.addTest('space command', ['keydown']);
// will not work in firefox
// there is currently no way to prevent default on each key in a sequence
// PeanutButter.addTest('command+k command+u', ['keyup']);
PeanutButter.spread();
</script>
</body>