js_lis 1.0.18 → 1.0.21
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 +87 -79
- package/package.json +1 -1
package/VirtualKeyboard.js
CHANGED
|
@@ -144,9 +144,11 @@ export class VirtualKeyboard {
|
|
|
144
144
|
keyElement.className += ' space';
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
if (key === 'backspace') {
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
if (key === 'backspace' || key === 'Backspace') {
|
|
148
|
+
keyElement.className += ' backspacew';
|
|
149
|
+
keyElement.innerHTML = '<i class="fa fa-backspace"></i>';
|
|
150
|
+
}
|
|
151
|
+
|
|
150
152
|
|
|
151
153
|
keyElement.onclick = (e) => {
|
|
152
154
|
e.preventDefault();
|
|
@@ -264,15 +266,81 @@ export class VirtualKeyboard {
|
|
|
264
266
|
}
|
|
265
267
|
|
|
266
268
|
toggleCapsLock() {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
this.capsLockActive = !this.capsLockActive;
|
|
270
|
+
document.querySelectorAll('.key[data-key="Caps"]').forEach((key) => {
|
|
271
|
+
key.classList.toggle("active", this.capsLockActive);
|
|
272
|
+
key.classList.toggle("bg-gray-400", this.capsLockActive);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
document.querySelectorAll(".key").forEach((key) => {
|
|
276
|
+
if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
|
|
277
|
+
key.textContent = this.capsLockActive
|
|
278
|
+
? key.dataset.key.toUpperCase()
|
|
279
|
+
: key.dataset.key.toLowerCase();
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const keyboardKeys = document.querySelectorAll(
|
|
284
|
+
".key:not([data-key='Caps'])"
|
|
285
|
+
);
|
|
286
|
+
keyboardKeys.forEach((key) => {
|
|
287
|
+
const currentChar = key.textContent.trim();
|
|
288
|
+
if (
|
|
289
|
+
this.capsLockActive &&
|
|
290
|
+
this.currentLayout === "th" &&
|
|
291
|
+
this.ThaiAlphabetShift[currentChar]
|
|
292
|
+
) {
|
|
293
|
+
key.textContent = this.ThaiAlphabetShift[currentChar];
|
|
294
|
+
key.dataset.key = this.ThaiAlphabetShift[currentChar];
|
|
295
|
+
} else if (
|
|
296
|
+
!this.capsLockActive &&
|
|
297
|
+
this.currentLayout === "th" &&
|
|
298
|
+
Object.values(this.ThaiAlphabetShift).includes(currentChar)
|
|
299
|
+
) {
|
|
300
|
+
// เปลี่ยนกลับเมื่อปิด Shift
|
|
301
|
+
const originalKey = Object.keys(this.ThaiAlphabetShift).find(
|
|
302
|
+
(key) => this.ThaiAlphabetShift[key] === currentChar
|
|
303
|
+
);
|
|
304
|
+
if (originalKey) {
|
|
305
|
+
key.textContent = originalKey;
|
|
306
|
+
key.dataset.key = originalKey;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (
|
|
311
|
+
this.capsLockActive &&
|
|
312
|
+
this.currentLayout === "en" &&
|
|
313
|
+
this.EngAlphabetShift[currentChar]
|
|
314
|
+
) {
|
|
315
|
+
key.textContent = this.EngAlphabetShift[currentChar];
|
|
316
|
+
key.dataset.key = this.EngAlphabetShift[currentChar];
|
|
317
|
+
} else if (
|
|
318
|
+
!this.capsLockActive &&
|
|
319
|
+
this.currentLayout === "en" &&
|
|
320
|
+
Object.values(this.EngAlphabetShift).includes(currentChar)
|
|
321
|
+
) {
|
|
322
|
+
// เปลี่ยนกลับเมื่อปิด Shift
|
|
323
|
+
const originalKey = Object.keys(this.EngAlphabetShift).find(
|
|
324
|
+
(key) => this.EngAlphabetShift[key] === currentChar
|
|
325
|
+
);
|
|
326
|
+
if (originalKey) {
|
|
327
|
+
key.textContent = originalKey;
|
|
328
|
+
key.dataset.key = originalKey;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
toggleShift() {
|
|
335
|
+
this.shiftActive = !this.shiftActive;
|
|
336
|
+
document.querySelectorAll('.key[data-key="Shift"]').forEach((key) => {
|
|
337
|
+
key.classList.toggle("active", this.shiftActive);
|
|
338
|
+
key.classList.toggle("bg-gray-400", this.shiftActive);
|
|
271
339
|
});
|
|
272
340
|
|
|
273
341
|
document.querySelectorAll(".key").forEach((key) => {
|
|
274
342
|
if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
|
|
275
|
-
key.textContent = this.
|
|
343
|
+
key.textContent = this.shiftActive
|
|
276
344
|
? key.dataset.key.toUpperCase()
|
|
277
345
|
: key.dataset.key.toLowerCase();
|
|
278
346
|
}
|
|
@@ -284,19 +352,19 @@ export class VirtualKeyboard {
|
|
|
284
352
|
keyboardKeys.forEach((key) => {
|
|
285
353
|
const currentChar = key.textContent.trim();
|
|
286
354
|
if (
|
|
287
|
-
this.
|
|
355
|
+
this.shiftActive &&
|
|
288
356
|
this.currentLayout === "th" &&
|
|
289
357
|
this.ThaiAlphabetShift[currentChar]
|
|
290
358
|
) {
|
|
291
359
|
key.textContent = this.ThaiAlphabetShift[currentChar];
|
|
292
360
|
key.dataset.key = this.ThaiAlphabetShift[currentChar];
|
|
293
361
|
} else if (
|
|
294
|
-
!this.
|
|
362
|
+
!this.shiftActive &&
|
|
295
363
|
this.currentLayout === "th" &&
|
|
296
364
|
Object.values(this.ThaiAlphabetShift).includes(currentChar)
|
|
297
365
|
) {
|
|
298
366
|
// เปลี่ยนกลับเมื่อปิด Shift
|
|
299
|
-
const originalKey = Object.keys(ThaiAlphabetShift).find(
|
|
367
|
+
const originalKey = Object.keys(this.ThaiAlphabetShift).find(
|
|
300
368
|
(key) => this.ThaiAlphabetShift[key] === currentChar
|
|
301
369
|
);
|
|
302
370
|
if (originalKey) {
|
|
@@ -304,88 +372,28 @@ export class VirtualKeyboard {
|
|
|
304
372
|
key.dataset.key = originalKey;
|
|
305
373
|
}
|
|
306
374
|
}
|
|
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];
|
|
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
|
-
}
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
375
|
|
|
329
|
-
toggleShift() {
|
|
330
|
-
this.shiftActive = !this.shiftActive;
|
|
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
|
-
});
|
|
335
|
-
|
|
336
|
-
document.querySelectorAll(".key").forEach((key) => {
|
|
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
|
-
}
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
const keyboardKeys = document.querySelectorAll(
|
|
345
|
-
".key:not([data-key='Shift'])"
|
|
346
|
-
);
|
|
347
|
-
keyboardKeys.forEach((key) => {
|
|
348
|
-
const currentChar = key.textContent.trim();
|
|
349
376
|
if (
|
|
350
377
|
this.shiftActive &&
|
|
351
|
-
this.currentLayout === "
|
|
352
|
-
this.
|
|
378
|
+
this.currentLayout === "en" &&
|
|
379
|
+
this.EngAlphabetShift[currentChar]
|
|
353
380
|
) {
|
|
354
|
-
key.textContent = this.
|
|
355
|
-
key.dataset.key = this.
|
|
381
|
+
key.textContent = this.EngAlphabetShift[currentChar];
|
|
382
|
+
key.dataset.key = this.EngAlphabetShift[currentChar];
|
|
356
383
|
} else if (
|
|
357
384
|
!this.shiftActive &&
|
|
358
|
-
this.currentLayout === "
|
|
359
|
-
Object.values(this.
|
|
385
|
+
this.currentLayout === "en" &&
|
|
386
|
+
Object.values(this.EngAlphabetShift).includes(currentChar)
|
|
360
387
|
) {
|
|
361
388
|
// เปลี่ยนกลับเมื่อปิด Shift
|
|
362
|
-
const originalKey = Object.keys(
|
|
363
|
-
(key) => this.
|
|
389
|
+
const originalKey = Object.keys(this.EngAlphabetShift).find(
|
|
390
|
+
(key) => this.EngAlphabetShift[key] === currentChar
|
|
364
391
|
);
|
|
365
392
|
if (originalKey) {
|
|
366
393
|
key.textContent = originalKey;
|
|
367
394
|
key.dataset.key = originalKey;
|
|
368
395
|
}
|
|
369
396
|
}
|
|
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
|
-
}
|
|
389
397
|
});
|
|
390
398
|
}
|
|
391
399
|
|