-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkeyboardlearn.html
More file actions
353 lines (337 loc) 路 13.2 KB
/
Copy pathkeyboardlearn.html
File metadata and controls
353 lines (337 loc) 路 13.2 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<html>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<style>
body{
font-family: 'Roboto';
background-color: #221a0f;
}
#text{
font-family: 'Roboto';
height: 60px;
}
#instruct{
color: white;
font-size: clamp(1rem, 8vw, 4rem);
text-align: center;
}
.row{
width: 84vw;
margin-left: 7vw;
margin-right: 5vw;
background-color: #fdf6e3;
height: 6vw;
}
.key{
float: left;
height: 5vw;
width: 5vw;
margin: 0.5%;
background-color: #cb4b16;
text-align: center;
color: #fdf6e3;
font-size: 3vw;
}
.key:active{
background-color: #859900;
}
#Tab, #Backspace{
width: 7vw;
}
#CapsLock, #ShiftLeft, #ShiftRight, #Tab, #Enter{
background-color: #657b83;
text-decoration: underline;
}
#CapsLock{
width: 8vw;
}
#Enter{
width: 10vw;
}
#Space{
width: 83vw;
}
#Backspace{
background-color: #2aa198;
font-style: italic;
}
#ShiftLeft, #ShiftRight{
width: 11.9vw;
}
#text, #custom{
background-color: #2aa198;
width: 84vw;
margin-left: 7vw;
margin-right: 5vw;
resize: none;
/*height: 15vw;*/
margin-top: 2vw;
border: none;
outline: none;
color: #fdf6e3;
font-size: 3vw;
}
#custom{
height: 25vw;
background-color: #dc322f;
}
h2{
float: left;
color: #fdf6e3;
margin: 5vw;
font-size: 3vw;
width: 90vw;
}
#thespan{
color: #dc322f;
}
</style>
<link rel="shortcut icon" href="favicon.ico?">
<title>Learn Osage Keyboard</title>
</head>
<body>
<div id="keyboard">
<div class="row" id="row0">
<div class="key" id="Backquote" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit1" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit2" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit3" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit4" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit5" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit6" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit7" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit8" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit9" onclick="pressKey(this.id)"></div>
<div class="key" id="Digit0" onclick="pressKey(this.id)"></div>
<div class="key" id="Minus" onclick="pressKey(this.id)"></div>
<div class="key" id="Equal" onclick="pressKey(this.id)"></div>
<div class="key" id="Backspace" onclick="pressKey(this.id)"></div>
</div>
<div class="row" id="row1">
<div class="key" id="Tab"></div>
<div class="key" id="KeyQ" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyW" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyE" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyR" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyT" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyY" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyU" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyI" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyO" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyP" onclick="pressKey(this.id)"></div>
<div class="key" id="BracketLeft" onclick="pressKey(this.id)"></div>
<div class="key" id="BracketRight" onclick="pressKey(this.id)"></div>
<div class="key" id="Backslash" onclick="pressKey(this.id)"></div>
</div>
<div class="row" id="row2">
<div class="key" id="CapsLock"></div>
<div class="key" id="KeyA" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyS" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyD" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyF" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyG" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyH" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyJ" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyK" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyL" onclick="pressKey(this.id)"></div>
<div class="key" id="Semicolon" onclick="pressKey(this.id)"></div>
<div class="key" id="Quote" onclick="pressKey(this.id)"></div>
<div class="key" id="Enter"></div>
</div>
<div class="row" id="row3">
<div class="key" id="ShiftLeft" onclick="leshift()"></div>
<div class="key" id="KeyZ" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyX" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyC" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyV" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyB" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyN" onclick="pressKey(this.id)"></div>
<div class="key" id="KeyM" onclick="pressKey(this.id)"></div>
<div class="key" id="Comma" onclick="pressKey(this.id)"></div>
<div class="key" id="Period" onclick="pressKey(this.id)"></div>
<div class="key" id="Slash" onclick="pressKey(this.id)"></div>
<div class="key" id="ShiftRight" onclick="leshift()"></div>
</div>
<div class="row" id="row4">
<div class="key" id="Space" onclick="space()">s p a c e</div>
</div>
</div>
<textarea id="text" spellcheck="false"></textarea>
<textarea id="custom" style="display:none" onkeypress="customKeySet()"></textarea>
<p id="instruct">Type <span id="thespan">饜捁饜搨</span> (<span id="definition">fish</span>)</p>
<script>
vocab = {
"饜捊饜挵蜆饜搳饜挿": "apple",
"饜搻饜搸饜搷饜挵": "eagle",
"饜搹饜捇饜搨饜搷饜挵饜搯饜搫饜挿": "cork",
"饜搷饜挵蜆饜搶饜挵饜摀饜捇": "improbably",
"饜搱饜搨蜆饜搫饜挿饜搹饜挶": "chair",
"饜捇饜捒饜搸饜挿饜捈'饜捇": "spittoon",
"饜捈饜挵饜搰饜搫饜挿饜搨蜆饜搫饜挵": "quarter (coin)",
"饜捊饜捇饜搯饜搱饜搨饜搵饜捇": "courthouse",
"饜搹饜挵饜捁饜搨饜搰饜挼饜挵饜摀饜捇蜆": "tiny",
"饜捈饜挵饜搰饜搩饜捈饜挿": "good-bye!",
"饜挵饜捈饜挵饜捁饜挵饜搮饜挵": "vest",
"饜捊饜捇饜捒饜搨蜆饜搼饜挿饜搥饜挷": "honey",
"饜捁饜搸饜搲饜挵蜆饜捈饜挵": "many, lots of",
"饜搥饜捇蜆饜搷饜搨饜搲饜挵饜搹饜挵饜搧饜搨蜆饜挻饜挿": "noon meal",
"饜搹饜捇饜挾饜搨饜搰饜搫饜挵": "my grandchild",
"饜搹饜挵饜搯饜挿饜搲饜挵蜆饜捄饜搸": "sycamore tree",
}
function vcab(){
vocab = Object.entries(vocab)
vocab = vocab.sort((a, b) => 0.5 - Math.random())
vocab = vocab.sort((a, b) => 0.5 - Math.random())
vocab = vocab.sort((a, b) => 0.5 - Math.random())
vocab = vocab.sort((a, b) => 0.5 - Math.random())
vocab = vocab.sort((a, b) => 0.5 - Math.random())
vocab = vocab.sort((a, b) => 0.5 - Math.random())
console.log(vocab)
vCount = 0
}
vcab()
document.addEventListener('keypress', function(e){
if(e.code != "Space"/* && e.code != "Enter"*/){
event.preventDefault()
pressKey(e.code)
}
else if(e.code == "Space"){
document.getElementById(e.code).style.backgroundColor = "#859900"
}
});
document.addEventListener('keydown', function(e){
if(e.code.startsWith("Shift")){
KeyE.textContent = "饜捀"
KeyU.textContent = "饜挸"
KeyI.textContent = "饜挶"
KeyA.textContent = "饜挷"
KeyH.textContent = "饜捄"
KeyC.textContent = "饜挾"
}
if(!["Space", "CapsLock", "ShiftLeft", "ShiftRight", "Tab", "Enter"].includes(e.code)) document.getElementById(e.code).style.backgroundColor = "#859900"
if(e.code == "Backspace"/* || e.code == "Enter"*/) document.getElementById(e.code).style.backgroundColor = "#859900"
});
document.addEventListener('keyup', function(e){
if(e.code.startsWith("Shift")){
KeyE.textContent = "饜挿"
KeyU.textContent = "饜搸"
KeyI.textContent = "饜捇"
KeyA.textContent = "饜挵"
KeyH.textContent = "饜捁"
KeyC.textContent = "饜挼"
}
if(e.code == "Backspace"/* || e.code == "Enter"*/) document.getElementById(e.code).style.backgroundColor = "#2aa198"
else if(e.code.startsWith("Key") || e.code.startsWith("Digit") || ["Backquote", "Minus", "Equal", "Comma", "Period", "Slash", "BracketLeft", "BracketRight", "Backslash", "Semicolon", "Quote", "Space"].includes(e.code)) document.getElementById(e.code).style.backgroundColor = e.code != "Backspace" ? "#cb4b16" : "#d33682"
console.log(text.value.trim())
console.log(thespan.textContent)
console.log(text.value.trim() == thespan.textContent)
if(text.value.trim() == thespan.textContent){
vCount++
if(vocab.length < vCount){
alert("Great! Let's try again")
vCount = 0
}
thespan.textContent = vocab[vCount][0]
definition.textContent = vocab[vCount][1]
text.value = ""
}
console.log(text.value)
});
/*document.body.onmousedown = function(e){
if(e.path[0].id == "Enter") text.value += "\r"
else if(e.path[0].classList[0] == "key" && !(["Tab", "ShiftLeft", "ShiftRight", "Enter", "CapsLock"].includes(e.path[0].id))){
pressKey(e.srcElement.id)
}
}
document.body.onmouseup = function(e){
if(e.path[0].classList[0] == "key" && !(["Tab", "ShiftLeft", "ShiftRight", "Enter", "CapsLock"].includes(e.path[0].id))){
document.getElementById(e.path[0].id).style.backgroundColor = e.path[0].id != "Backspace" ? "#cb4b16" : "#d33682"
//e.path[0].style.backgroundColor = "black"
//e.path[0].style.backgroundColor = e.path[0].id != "Backspace" ? "#cb4b16" : "#d33682"
}
}*/
function pressKey(k){
console.log('h')
n = text.selectionStart + document.getElementById(k).textContent.length
if(k != "Backspace"){
if(k != "Enter"){
text.value += document.getElementById(k).textContent
}
}
else{
text.value = Array.from(text.value).slice(0,-1).join("")
}
text.selectionStart = n
text.value = text.value.replace("a台", "膮")
}
function leshift(){
alert('leshift')
}
function space(){
text.value += " "
}
keyboards = {
Osage: {
Backquote:"'",
Digit1:1,
Digit2:2,
Digit3:3,
Digit4:4,
Digit5:5,
Digit6:6,
Digit7:7,
Digit8:8,
Digit9:9,
Digit0:0,
Minus:"?",
Equal:",",
Backspace:"del",
CapsLock:"caps",
Enter:"return",
ShiftLeft:"shift",
ShiftRight:"shift",
Tab:"tab",
KeyQ:"饜捑",
KeyW:"饜搹",
KeyE:"饜挿",
KeyR:"饜搳",
KeyT:"饜搷",
KeyY:"饜摀",
KeyU:"饜搸",
KeyI:"饜捇",
KeyO:"饜搨",
KeyP:"饜搫",
BracketLeft:"饜搮",
BracketRight:"饜挷",
Backslash:"饜挶",
KeyA:"饜挵",
KeyS:"饜搯",
KeyD:"饜搱",
KeyF:"饜搲",
KeyJ:"蜆",
KeyH:"饜捁",
KeyG:"饜捈",
KeyK:"饜捊",
KeyL:"饜捒",
Semicolon:"饜搵",
Quote:"饜搶",
KeyZ:"饜搾",
KeyX:"饜搻",
KeyC:"饜挼",
KeyV:"饜搰",
KeyB:"饜挻",
KeyN:"饜搧",
KeyM:"饜搥",
Comma:"饜搼",
Period:".",
Slash:"饜搩",
},
}
function keySet(lang){
for(n of Object.entries(keyboards[lang])) document.getElementById(n[0]).textContent = n[1]
}
keySet("Osage")
console.log("QWERTYUIOPASDFGHJKLZXCVBNM".split("").map(r => `Key${r}`).concat(["Backquote", "Minus", "Equal", "BracketLeft", "BracketRight", "Backslash", "Semicolon", "Quote", "Comma", "Period", "Slash"]))
</script>
</html>