js_lis 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VirtualKeyboard.js +126 -70
- package/layouts.js +13 -13
- package/package.json +1 -1
package/VirtualKeyboard.js
CHANGED
|
@@ -262,88 +262,144 @@ export class VirtualKeyboard {
|
|
|
262
262
|
this.currentInput.value = this.currentInput.value.slice(0, start) + decodedText + this.currentInput.value.slice(end);
|
|
263
263
|
this.currentInput.selectionStart = this.currentInput.selectionEnd = start + decodedText.length;
|
|
264
264
|
}
|
|
265
|
-
|
|
265
|
+
|
|
266
266
|
toggleCapsLock() {
|
|
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
|
-
|
|
267
|
+
this.capsLockActive = !this.capsLockActive;
|
|
268
|
+
document.querySelectorAll('.key[data-key="Caps"]').forEach((key) => {
|
|
269
|
+
key.classList.toggle("active", this.capsLockActive);
|
|
270
|
+
key.classList.toggle("bg-gray-400", this.capsLockActive);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
document.querySelectorAll(".key").forEach((key) => {
|
|
274
|
+
if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
|
|
275
|
+
key.textContent = this.capsLockActive
|
|
276
|
+
? key.dataset.key.toUpperCase()
|
|
277
|
+
: key.dataset.key.toLowerCase();
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
const keyboardKeys = document.querySelectorAll(
|
|
282
|
+
".key:not([data-key='Caps'])"
|
|
283
|
+
);
|
|
284
|
+
keyboardKeys.forEach((key) => {
|
|
285
|
+
const currentChar = key.textContent.trim();
|
|
286
|
+
if (
|
|
287
|
+
this.capsLockActive &&
|
|
288
|
+
this.currentLayout === "th" &&
|
|
289
|
+
this.ThaiAlphabetShift[currentChar]
|
|
290
|
+
) {
|
|
291
|
+
key.textContent = this.ThaiAlphabetShift[currentChar];
|
|
292
|
+
key.dataset.key = this.ThaiAlphabetShift[currentChar];
|
|
293
|
+
} else if (
|
|
294
|
+
!this.capsLockActive &&
|
|
295
|
+
this.currentLayout === "th" &&
|
|
296
|
+
Object.values(this.ThaiAlphabetShift).includes(currentChar)
|
|
297
|
+
) {
|
|
298
|
+
// เปลี่ยนกลับเมื่อปิด Shift
|
|
299
|
+
const originalKey = Object.keys(ThaiAlphabetShift).find(
|
|
300
|
+
(key) => this.ThaiAlphabetShift[key] === currentChar
|
|
301
|
+
);
|
|
302
|
+
if (originalKey) {
|
|
303
|
+
key.textContent = originalKey;
|
|
304
|
+
key.dataset.key = originalKey;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (
|
|
309
|
+
this.capsLockActive &&
|
|
310
|
+
this.currentLayout === "th" &&
|
|
311
|
+
this.EngAlphabetShift[currentChar]
|
|
312
|
+
) {
|
|
313
|
+
key.textContent = this.EngAlphabetShift[currentChar];
|
|
314
|
+
key.dataset.key = this.EngAlphabetShift[currentChar];
|
|
315
|
+
} else if (
|
|
316
|
+
!this.capsLockActive &&
|
|
317
|
+
this.currentLayout === "th" &&
|
|
318
|
+
Object.values(this.EngAlphabetShift).includes(currentChar)
|
|
319
|
+
) {
|
|
320
|
+
// เปลี่ยนกลับเมื่อปิด Shift
|
|
321
|
+
const originalKey = Object.keys(EngAlphabetShift).find(
|
|
322
|
+
(key) => this.EngAlphabetShift[key] === currentChar
|
|
323
|
+
);
|
|
324
|
+
if (originalKey) {
|
|
325
|
+
key.textContent = originalKey;
|
|
326
|
+
key.dataset.key = originalKey;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
306
332
|
toggleShift() {
|
|
307
333
|
this.shiftActive = !this.shiftActive;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
334
|
+
document.querySelectorAll('.key[data-key="Shift"]').forEach((key) => {
|
|
335
|
+
key.classList.toggle("active", this.shiftActive);
|
|
336
|
+
key.classList.toggle("bg-gray-400", this.shiftActive);
|
|
337
|
+
});
|
|
311
338
|
|
|
312
339
|
document.querySelectorAll(".key").forEach((key) => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
340
|
+
if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
|
|
341
|
+
key.textContent = this.shiftActive
|
|
342
|
+
? key.dataset.key.toUpperCase()
|
|
343
|
+
: key.dataset.key.toLowerCase();
|
|
344
|
+
}
|
|
319
345
|
});
|
|
320
346
|
|
|
321
|
-
const keyboardKeys = document.querySelectorAll(
|
|
347
|
+
const keyboardKeys = document.querySelectorAll(
|
|
348
|
+
".key:not([data-key='Shift'])"
|
|
349
|
+
);
|
|
322
350
|
keyboardKeys.forEach((key) => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
351
|
+
const currentChar = key.textContent.trim();
|
|
352
|
+
if (
|
|
353
|
+
this.shiftActive &&
|
|
354
|
+
this.currentLayout === "th" &&
|
|
355
|
+
this.ThaiAlphabetShift[currentChar]
|
|
356
|
+
) {
|
|
357
|
+
key.textContent = this.ThaiAlphabetShift[currentChar];
|
|
358
|
+
key.dataset.key = this.ThaiAlphabetShift[currentChar];
|
|
359
|
+
} else if (
|
|
360
|
+
!this.shiftActive &&
|
|
361
|
+
this.currentLayout === "th" &&
|
|
362
|
+
Object.values(this.ThaiAlphabetShift).includes(currentChar)
|
|
363
|
+
) {
|
|
364
|
+
// เปลี่ยนกลับเมื่อปิด Shift
|
|
365
|
+
const originalKey = Object.keys(ThaiAlphabetShift).find(
|
|
366
|
+
(key) => this.ThaiAlphabetShift[key] === currentChar
|
|
367
|
+
);
|
|
368
|
+
if (originalKey) {
|
|
369
|
+
key.textContent = originalKey;
|
|
370
|
+
key.dataset.key = originalKey;
|
|
343
371
|
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (
|
|
375
|
+
this.shiftActive &&
|
|
376
|
+
this.currentLayout === "th" &&
|
|
377
|
+
this.EngAlphabetShift[currentChar]
|
|
378
|
+
) {
|
|
379
|
+
key.textContent = this.EngAlphabetShift[currentChar];
|
|
380
|
+
key.dataset.key = this.EngAlphabetShift[currentChar];
|
|
381
|
+
} else if (
|
|
382
|
+
!this.shiftActive &&
|
|
383
|
+
this.currentLayout === "th" &&
|
|
384
|
+
Object.values(this.EngAlphabetShift).includes(currentChar)
|
|
385
|
+
) {
|
|
386
|
+
// เปลี่ยนกลับเมื่อปิด Shift
|
|
387
|
+
const originalKey = Object.keys(EngAlphabetShift).find(
|
|
388
|
+
(key) => this.EngAlphabetShift[key] === currentChar
|
|
389
|
+
);
|
|
390
|
+
if (originalKey) {
|
|
391
|
+
key.textContent = originalKey;
|
|
392
|
+
key.dataset.key = originalKey;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
344
395
|
});
|
|
345
396
|
}
|
|
346
397
|
|
|
398
|
+
EngAlphabetShift = {
|
|
399
|
+
"`": "~", 1: "!", 2: "@", 3: "#", 4: "$", 5: "%", 6: "^", 7: "&", 8: "*", 9: "(", 0: ")", "-": "_", "=": "+",
|
|
400
|
+
"[": "{", "]": "}", "\\": "|", ";": ":", "'": '"', ",": "<", ".": ">", "/": "?"
|
|
401
|
+
};
|
|
402
|
+
|
|
347
403
|
ThaiAlphabetShift = {
|
|
348
404
|
_: "%",
|
|
349
405
|
ๅ: "+",
|
package/layouts.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export const layouts = {
|
|
2
2
|
en: [
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "Backspace"],
|
|
4
|
+
["Tab", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "\\"],
|
|
5
|
+
["Caps", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "Enter"],
|
|
6
|
+
["Shift", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "Shift"],
|
|
7
|
+
["Space"],
|
|
8
8
|
],
|
|
9
9
|
th: [
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
["_", "ๅ", "/", "-", "ภ", "ถ", "ุ", "ึ", "ค", "ต", "จ", "ข", "ช", "Backspace"],
|
|
11
|
+
["Tab", "ๆ", "ไ", "ำ", "พ", "ะ", "ั", "ี", "ร", "น", "ย", "บ", "ล", "ฃ"],
|
|
12
|
+
["Caps", "ฟ", "ห", "ก", "ด", "เ", "้", "่", "า", "ส", "ว", "ง", "Enter"],
|
|
13
|
+
["Shift", "ผ", "ป", "แ", "อ", "ิ", "ื", "ท", "ม", "ใ", "ฝ", "Shift"],
|
|
14
|
+
["Space"],
|
|
15
15
|
],
|
|
16
16
|
numpad: [
|
|
17
17
|
["+", "-", "*", "/"],
|
|
@@ -20,14 +20,14 @@ export const layouts = {
|
|
|
20
20
|
["7", "8", "9", "="],
|
|
21
21
|
["00", "0", "backspace"],
|
|
22
22
|
],
|
|
23
|
-
scNum
|
|
23
|
+
scNum: [
|
|
24
24
|
["+", "-", "*", "/"],
|
|
25
25
|
["1", "2", "3", "%"],
|
|
26
26
|
["4", "5", "6", "."],
|
|
27
27
|
["7", "8", "9", "="],
|
|
28
28
|
["00", "0", "backspace"],
|
|
29
29
|
],
|
|
30
|
-
thSc
|
|
30
|
+
thSc: [
|
|
31
31
|
["ก", "ข", "ฃ", "ค", "ฅ", "ฆ", "ง", "จ", "ฉ", "ช", "ซ", "ฌ", "Backspace"],
|
|
32
32
|
["ญ", "ฎ", "ฏ", "ฐ", "ฑ", "ฒ", "ณ", "ด", "ต", "ถ", "ท", "ธ", "น"],
|
|
33
33
|
["บ", "ป", "ผ", "ฝ", "พ", "ฟ", "ภ", "ม", "ย", "ร", "ฤ", "Enter"],
|
|
@@ -41,4 +41,4 @@ export const layouts = {
|
|
|
41
41
|
["Shift", "z", "x", "c", "v", "b", "n", "m", "Shift"],
|
|
42
42
|
["Space"],
|
|
43
43
|
],
|
|
44
|
-
};
|
|
44
|
+
};
|