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.
@@ -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
- this.capsLockActive = !this.capsLockActive;
268
- const capsKey = document.querySelector('.key[data-key="Caps"]');
269
- capsKey.classList.toggle("active", this.capsLockActive);
270
- capsKey.classList.toggle("bg-gray-400", this.capsLockActive);
271
-
272
- document.querySelectorAll(".key").forEach((key) => {
273
- if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
274
- key.textContent = this.capsLockActive
275
- ? key.dataset.key.toUpperCase()
276
- : key.dataset.key.toLowerCase();
277
- }
278
- });
279
-
280
- const keyboardKeys = document.querySelectorAll(".key:not([data-key='Shift'])");
281
- keyboardKeys.forEach((key) => {
282
- const currentChar = key.textContent.trim();
283
- if (
284
- this.capsLockActive &&
285
- this.currentLayout === "th" &&
286
- this.ThaiAlphabetShift[currentChar]
287
- ) {
288
- key.textContent = this.ThaiAlphabetShift[currentChar];
289
- key.dataset.key = this.ThaiAlphabetShift[currentChar];
290
- } else if (
291
- !this.capsLockActive &&
292
- this.currentLayout === "th" &&
293
- Object.values(this.ThaiAlphabetShift).includes(currentChar)
294
- ) {
295
- const originalKey = Object.keys(this.ThaiAlphabetShift).find(
296
- (key) => this.ThaiAlphabetShift[key] === currentChar
297
- );
298
- if (originalKey) {
299
- key.textContent = originalKey;
300
- key.dataset.key = originalKey;
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
- const shiftKey = document.querySelector('.key[data-key="Shift"]');
309
- shiftKey.classList.toggle("active", this.shiftActive);
310
- shiftKey.classList.toggle("bg-gray-400", this.shiftActive);
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
- if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
314
- // แสดงผลตัวพิมพ์ใหญ่หรือเล็กตามค่า Shift
315
- key.textContent = this.shiftActive
316
- ? key.dataset.key.toUpperCase()
317
- : key.dataset.key.toLowerCase();
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(".key:not([data-key='Shift'])");
347
+ const keyboardKeys = document.querySelectorAll(
348
+ ".key:not([data-key='Shift'])"
349
+ );
322
350
  keyboardKeys.forEach((key) => {
323
- const currentChar = key.textContent.trim();
324
- if (
325
- this.shiftActive &&
326
- this.currentLayout === "th" && // ตรวจสอบว่ากำลังใช้เลย์เอาต์ภาษาไทย
327
- this.ThaiAlphabetShift[currentChar]
328
- ) {
329
- key.textContent = this.ThaiAlphabetShift[currentChar]; // แสดงอักษรจาก shift
330
- key.dataset.key = this.ThaiAlphabetShift[currentChar]; // อัปเดต dataset.key
331
- } else if (
332
- !this.shiftActive &&
333
- this.currentLayout === "th" &&
334
- Object.values(this.ThaiAlphabetShift).includes(currentChar)
335
- ) {
336
- const originalKey = Object.keys(this.ThaiAlphabetShift).find(
337
- (key) => this.ThaiAlphabetShift[key] === currentChar
338
- );
339
- if (originalKey) {
340
- key.textContent = originalKey;
341
- key.dataset.key = originalKey;
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
- ['`', '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']
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
- ['_', '', '/', '-', '', '', '', '', '', '', '', '', '', 'Backspace'],
11
- ['Tab', '', '', '', '', '', '', '', '', '', '', '', '', ''],
12
- ['Caps', '', '', '', '', '', '', '', '', '', '', '', 'Enter'],
13
- ['Shift', '', '', '', '', '', '', '', '', '', '', 'Shift'],
14
- ['Space']
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_lis",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"