forked from mapbox/react-keybinding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax.js
40 lines (30 loc) · 1.08 KB
/
syntax.js
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
var fs = require('fs');
var codes = require('./src/codes');
/**
* This file generates the file SYNTAX.md, which lists
* all of the available key combinations supported by this mixin.
*/
function pairs(o) {
return Object.keys(o).map(function(k) { return [k, o[k]]; });
}
var out = fs.createWriteStream('SYNTAX.md', { flags: 'w' });
out.write('# Syntax\n\n');
out.write('## keyCodes\n\n');
out.write('| input | keyCode |\n');
out.write('|------------|------------------|\n');
pairs(codes.keyCodes).forEach(function(pair) {
out.write('| `` ' + pair[0] + ' `` | ' + pair[1] + ' |\n');
});
out.write('\n\n## shift key combinations\n\n');
out.write('| input | keyCode |\n');
out.write('|------------|------------------|\n');
pairs(codes.shiftedKeys).forEach(function(pair) {
out.write('| `` ' + pair[0] + ' `` | shift + ' + pair[1] + ' |\n');
});
out.write('\n\n## modifiers\n\n');
out.write('| input | keyCode |\n');
out.write('|------------|------------------|\n');
pairs(codes.modifierCodes).forEach(function(pair) {
out.write('| `` ' + pair[0] + ' `` | ' + pair[1] + ' |\n');
});
out.end();