Repository navigation
Expand file tree
/
Copy pathkeyboard.js
More file actions
39 lines (36 loc) · 1.99 KB
/
Copy pathkeyboard.js
File metadata and controls
39 lines (36 loc) · 1.99 KB
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
// keyboard.js: [label, code, width]
const LAYOUT = [
[['`','Backquote'],['1','Digit1'],['2','Digit2'],['3','Digit3'],['4','Digit4'],['5','Digit5'],['6','Digit6'],['7','Digit7'],['8','Digit8'],['9','Digit9'],['0','Digit0'],['-','Minus'],['=','Equal'],['Backspace','Backspace',1.7]],
[['Tab','Tab',1.5],['Q','KeyQ'],['W','KeyW'],['E','KeyE'],['R','KeyR'],['T','KeyT'],['Y','KeyY'],['U','KeyU'],['I','KeyI'],['O','KeyO'],['P','KeyP'],['[','BracketLeft'],[']','BracketRight'],['\\','Backslash',1.2]],
[['Caps','CapsLock',1.8],['A','KeyA'],['S','KeyS'],['D','KeyD'],['F','KeyF'],['G','KeyG'],['H','KeyH'],['J','KeyJ'],['K','KeyK'],['L','KeyL'],[';','Semicolon'],["'",'Quote'],['Enter','Enter',1.9]],
[['Shift','ShiftLeft',2.3],['Z','KeyZ'],['X','KeyX'],['C','KeyC'],['V','KeyV'],['B','KeyB'],['N','KeyN'],['M','KeyM'],[',','Comma'],['.','Period'],['/','Slash'],['Shift','ShiftRight',2.3]],
[['Ctrl','ControlLeft',1.3],['Win','MetaLeft'],['Alt','AltLeft',1.2],['Space','Space',6],['Alt','AltRight',1.2],['Ctrl','ControlRight',1.3],['←','ArrowLeft'],['↑','ArrowUp'],['↓','ArrowDown'],['→','ArrowRight']]
];
const keyboardEl = document.getElementById('keyboard');
LAYOUT.forEach(row => {
const r = document.createElement('div');
r.className = 'row';
row.forEach(([label, code, w = 1]) => {
const k = document.createElement('div');
k.className = 'key meh';
k.dataset.code = code;
k.style.flex = w;
k.innerHTML = label + '<span class="pct"></span><span class="face"></span>';
r.append(k);
});
keyboardEl.append(r);
});
// legend
const MOODS = [
['thriving','thriving'],['happy','happy'],['fine','fine'],['meh','meh'],
['sad','sad'],['jealous','jealous'],['blocked','blocked']
];
const legend = document.createElement('div');
legend.className = 'legend';
MOODS.forEach(([cls, name]) => {
const item = document.createElement('span');
item.className = 'legend-item';
item.innerHTML = '<i class="swatch ' + cls + '"></i>' + name;
legend.append(item);
});
keyboardEl.after(legend);