js_lis 1.0.17 → 1.0.18
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 +111 -61
- package/layouts.js +13 -13
- package/package.json +1 -1
package/VirtualKeyboard.js
CHANGED
|
@@ -262,88 +262,138 @@ 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
267
|
this.capsLockActive = !this.capsLockActive;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
+
});
|
|
271
272
|
|
|
272
273
|
document.querySelectorAll(".key").forEach((key) => {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
+
}
|
|
278
279
|
});
|
|
279
280
|
|
|
280
|
-
const keyboardKeys = document.querySelectorAll(
|
|
281
|
+
const keyboardKeys = document.querySelectorAll(
|
|
282
|
+
".key:not([data-key='Shift'])"
|
|
283
|
+
);
|
|
281
284
|
keyboardKeys.forEach((key) => {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
+
// Shift state for English layout
|
|
309
|
+
if (this.capsLockActive && this.currentLayout === "en") {
|
|
310
|
+
if (EngAlphabetShift[key.dataset.key]) {
|
|
311
|
+
key.textContent = this.EngAlphabetShift[key.dataset.key];
|
|
312
|
+
key.dataset.key = this.EngAlphabetShift[key.dataset.key];
|
|
302
313
|
}
|
|
314
|
+
} else if (!this.capsLockActive && this.currentLayout === "en") {
|
|
315
|
+
// Revert when shift is off
|
|
316
|
+
if (Object.values(EngAlphabetShift).includes(currentChar)) {
|
|
317
|
+
const originalKey = Object.keys(EngAlphabetShift).find(
|
|
318
|
+
(key) => EngAlphabetShift[key] === currentChar
|
|
319
|
+
);
|
|
320
|
+
if (originalKey) {
|
|
321
|
+
key.textContent = originalKey;
|
|
322
|
+
key.dataset.key = originalKey;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
303
326
|
});
|
|
304
327
|
}
|
|
305
|
-
|
|
328
|
+
|
|
306
329
|
toggleShift() {
|
|
307
330
|
this.shiftActive = !this.shiftActive;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
331
|
+
document.querySelectorAll('.key[data-key="Shift"]').forEach((key) => {
|
|
332
|
+
key.classList.toggle("active", this.shiftActive);
|
|
333
|
+
key.classList.toggle("bg-gray-400", this.shiftActive);
|
|
334
|
+
});
|
|
311
335
|
|
|
312
336
|
document.querySelectorAll(".key").forEach((key) => {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
337
|
+
if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
|
|
338
|
+
key.textContent = this.shiftActive
|
|
339
|
+
? key.dataset.key.toUpperCase()
|
|
340
|
+
: key.dataset.key.toLowerCase();
|
|
341
|
+
}
|
|
319
342
|
});
|
|
320
343
|
|
|
321
|
-
const keyboardKeys = document.querySelectorAll(
|
|
344
|
+
const keyboardKeys = document.querySelectorAll(
|
|
345
|
+
".key:not([data-key='Shift'])"
|
|
346
|
+
);
|
|
322
347
|
keyboardKeys.forEach((key) => {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
348
|
+
const currentChar = key.textContent.trim();
|
|
349
|
+
if (
|
|
350
|
+
this.shiftActive &&
|
|
351
|
+
this.currentLayout === "th" &&
|
|
352
|
+
this.ThaiAlphabetShift[currentChar]
|
|
353
|
+
) {
|
|
354
|
+
key.textContent = this.ThaiAlphabetShift[currentChar];
|
|
355
|
+
key.dataset.key = this.ThaiAlphabetShift[currentChar];
|
|
356
|
+
} else if (
|
|
357
|
+
!this.shiftActive &&
|
|
358
|
+
this.currentLayout === "th" &&
|
|
359
|
+
Object.values(this.ThaiAlphabetShift).includes(currentChar)
|
|
360
|
+
) {
|
|
361
|
+
// เปลี่ยนกลับเมื่อปิด Shift
|
|
362
|
+
const originalKey = Object.keys(ThaiAlphabetShift).find(
|
|
363
|
+
(key) => this.ThaiAlphabetShift[key] === currentChar
|
|
364
|
+
);
|
|
365
|
+
if (originalKey) {
|
|
366
|
+
key.textContent = originalKey;
|
|
367
|
+
key.dataset.key = originalKey;
|
|
343
368
|
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Shift state for English layout
|
|
372
|
+
if (this.shiftActive && this.currentLayout === "en") {
|
|
373
|
+
if (EngAlphabetShift[key.dataset.key]) {
|
|
374
|
+
key.textContent = this.EngAlphabetShift[key.dataset.key];
|
|
375
|
+
key.dataset.key = this.EngAlphabetShift[key.dataset.key];
|
|
376
|
+
}
|
|
377
|
+
} else if (!this.shiftActive && this.currentLayout === "en") {
|
|
378
|
+
// Revert when shift is off
|
|
379
|
+
if (Object.values(EngAlphabetShift).includes(currentChar)) {
|
|
380
|
+
const originalKey = Object.keys(EngAlphabetShift).find(
|
|
381
|
+
(key) => EngAlphabetShift[key] === currentChar
|
|
382
|
+
);
|
|
383
|
+
if (originalKey) {
|
|
384
|
+
key.textContent = originalKey;
|
|
385
|
+
key.dataset.key = originalKey;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
344
389
|
});
|
|
345
390
|
}
|
|
346
391
|
|
|
392
|
+
EngAlphabetShift = {
|
|
393
|
+
"`": "~", 1: "!", 2: "@", 3: "#", 4: "$", 5: "%", 6: "^", 7: "&", 8: "*", 9: "(", 0: ")", "-": "_", "=": "+",
|
|
394
|
+
"[": "{", "]": "}", "\\": "|", ";": ":", "'": '"', ",": "<", ".": ">", "/": "?"
|
|
395
|
+
};
|
|
396
|
+
|
|
347
397
|
ThaiAlphabetShift = {
|
|
348
398
|
_: "%",
|
|
349
399
|
ๅ: "+",
|
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
|
+
};
|