js_lis 1.0.4 → 1.0.6
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 +400 -0
- package/layouts.js +44 -0
- package/main.js +4 -0
- package/package.json +1 -1
- package/index.js +0 -312
- package/layout.js +0 -398
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { layouts } from './layouts.js';
|
|
2
|
+
|
|
3
|
+
export class VirtualKeyboard {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.currentLayout = 'en';
|
|
6
|
+
this.isVisible = false;
|
|
7
|
+
this.container = document.getElementById('keyboard-container');
|
|
8
|
+
this.currentInput = null; // เปลี่ยนจาก fixed input เป็น dynamic
|
|
9
|
+
this.layouts = layouts;
|
|
10
|
+
this.isDragging = false;
|
|
11
|
+
this.offsetX = 0;
|
|
12
|
+
this.offsetY = 0;
|
|
13
|
+
this.shiftActive = false;
|
|
14
|
+
this.capsLockActive = false;
|
|
15
|
+
this.render();
|
|
16
|
+
this.initializeInputListeners();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
initializeInputListeners() {
|
|
20
|
+
// เพิ่ม event listener สำหรับทุก input และ textarea
|
|
21
|
+
document.addEventListener('click', (e) => {
|
|
22
|
+
const target = e.target;
|
|
23
|
+
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
|
|
24
|
+
this.setCurrentInput(target);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// เพิ่ม event listener สำหรับ focus
|
|
29
|
+
document.addEventListener('focus', (e) => {
|
|
30
|
+
const target = e.target;
|
|
31
|
+
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
|
|
32
|
+
this.setCurrentInput(target);
|
|
33
|
+
}
|
|
34
|
+
}, true);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
setCurrentInput(inputElement) {
|
|
38
|
+
// ถ้ามี input เก่า ให้ลบ class active
|
|
39
|
+
if (this.currentInput) {
|
|
40
|
+
this.currentInput.classList.remove('keyboard-active');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// เซ็ต input ใหม่และเพิ่ม class active
|
|
44
|
+
this.currentInput = inputElement;
|
|
45
|
+
this.currentInput.classList.add('keyboard-active');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
render() {
|
|
49
|
+
const keyboard = document.createElement('div');
|
|
50
|
+
keyboard.className = 'virtual-keyboard';
|
|
51
|
+
keyboard.style.display = this.isVisible ? 'block' : 'none';
|
|
52
|
+
|
|
53
|
+
// Add the ID for easy reference in dragging
|
|
54
|
+
keyboard.id = 'keyboard';
|
|
55
|
+
|
|
56
|
+
const layout = this.layouts[this.currentLayout];
|
|
57
|
+
|
|
58
|
+
layout.forEach(row => {
|
|
59
|
+
const rowElement = document.createElement('div');
|
|
60
|
+
rowElement.className = 'keyboard-row';
|
|
61
|
+
|
|
62
|
+
row.forEach(key => {
|
|
63
|
+
const keyElement = document.createElement('button');
|
|
64
|
+
keyElement.className = 'keyboard-key key'; // Add key class
|
|
65
|
+
keyElement.textContent = key;
|
|
66
|
+
keyElement.type = 'button';
|
|
67
|
+
|
|
68
|
+
// Add data-key to each key for reference
|
|
69
|
+
keyElement.dataset.key = key;
|
|
70
|
+
|
|
71
|
+
if (key === 'Space') {
|
|
72
|
+
keyElement.className += ' space';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (key === 'backspace') {
|
|
76
|
+
keyElement.className += ' backspacew';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
keyElement.onclick = (e) => {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
const keyPressed = keyElement.dataset.key || keyElement.textContent;
|
|
82
|
+
if (keyPressed) {
|
|
83
|
+
this.handleKeyPress(keyPressed);
|
|
84
|
+
} else {
|
|
85
|
+
console.error("The key element does not have a valid key value.");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
rowElement.appendChild(keyElement);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
keyboard.appendChild(rowElement);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
this.container.innerHTML = '';
|
|
97
|
+
this.container.appendChild(keyboard);
|
|
98
|
+
|
|
99
|
+
if (this.currentLayout === "scNum") {
|
|
100
|
+
this.scrambleKeyboard();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.currentLayout === "enSc") {
|
|
104
|
+
this.scrambleEnglishKeys();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (this.currentLayout === "thSc") {
|
|
108
|
+
this.scrambleThaiKeys();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Add drag functionality to the keyboard
|
|
112
|
+
keyboard.addEventListener('mousedown', (event) => this.startDrag(event));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
handleKeyPress(keyPressed) {
|
|
116
|
+
if (!this.currentInput) return;
|
|
117
|
+
|
|
118
|
+
const start = this.currentInput.selectionStart;
|
|
119
|
+
const end = this.currentInput.selectionEnd;
|
|
120
|
+
const value = this.currentInput.value;
|
|
121
|
+
|
|
122
|
+
const isCapsActive = this.capsLockActive;
|
|
123
|
+
const isShiftActive = this.shiftActive;
|
|
124
|
+
|
|
125
|
+
const convertToCorrectCase = (char) => {
|
|
126
|
+
if (isCapsActive || isShiftActive) {
|
|
127
|
+
return char.toUpperCase();
|
|
128
|
+
}
|
|
129
|
+
return char.toLowerCase();
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// ตรวจสอบค่า keyPressed
|
|
133
|
+
if (!keyPressed) {
|
|
134
|
+
console.error("Invalid key pressed.");
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
switch(keyPressed) {
|
|
139
|
+
case 'Backspace':
|
|
140
|
+
case 'backspace':
|
|
141
|
+
if (start === end && start > 0) {
|
|
142
|
+
this.currentInput.value = value.slice(0, start - 1) + value.slice(end);
|
|
143
|
+
this.currentInput.selectionStart = this.currentInput.selectionEnd = start - 1;
|
|
144
|
+
} else {
|
|
145
|
+
this.currentInput.value = value.slice(0, start) + value.slice(end);
|
|
146
|
+
this.currentInput.selectionStart = this.currentInput.selectionEnd = start;
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
|
|
150
|
+
case 'Space':
|
|
151
|
+
this.insertText(' ');
|
|
152
|
+
break;
|
|
153
|
+
|
|
154
|
+
case 'Tab':
|
|
155
|
+
this.insertText('\t');
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
case 'Enter':
|
|
159
|
+
if (this.currentInput.tagName === 'TEXTAREA') {
|
|
160
|
+
this.insertText('\n');
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
|
|
164
|
+
case 'Caps':
|
|
165
|
+
this.toggleCapsLock();
|
|
166
|
+
break;
|
|
167
|
+
|
|
168
|
+
case 'Shift':
|
|
169
|
+
this.toggleShift();
|
|
170
|
+
break;
|
|
171
|
+
|
|
172
|
+
default:
|
|
173
|
+
this.insertText(convertToCorrectCase(keyPressed));
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (isShiftActive && !isCapsActive) {
|
|
178
|
+
this.toggleShift();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this.currentInput.focus();
|
|
182
|
+
const event = new Event('input', { bubbles: true });
|
|
183
|
+
this.currentInput.dispatchEvent(event);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
toggleCapsLock() {
|
|
187
|
+
this.capsLockActive = !this.capsLockActive;
|
|
188
|
+
const capsKey = document.querySelector('.key[data-key="Caps"]');
|
|
189
|
+
capsKey.classList.toggle("active", this.capsLockActive);
|
|
190
|
+
capsKey.classList.toggle("bg-gray-400", this.capsLockActive);
|
|
191
|
+
|
|
192
|
+
document.querySelectorAll(".key").forEach((key) => {
|
|
193
|
+
if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
|
|
194
|
+
key.textContent = this.capsLockActive
|
|
195
|
+
? key.dataset.key.toUpperCase()
|
|
196
|
+
: key.dataset.key.toLowerCase();
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const keyboardKeys = document.querySelectorAll(".key:not([data-key='Shift'])");
|
|
201
|
+
keyboardKeys.forEach((key) => {
|
|
202
|
+
const currentChar = key.textContent.trim();
|
|
203
|
+
if (
|
|
204
|
+
this.capsLockActive &&
|
|
205
|
+
this.currentLayout === "th" &&
|
|
206
|
+
this.ThaiAlphabetShift[currentChar]
|
|
207
|
+
) {
|
|
208
|
+
key.textContent = this.ThaiAlphabetShift[currentChar];
|
|
209
|
+
key.dataset.key = this.ThaiAlphabetShift[currentChar];
|
|
210
|
+
} else if (
|
|
211
|
+
!this.capsLockActive &&
|
|
212
|
+
this.currentLayout === "th" &&
|
|
213
|
+
Object.values(this.ThaiAlphabetShift).includes(currentChar)
|
|
214
|
+
) {
|
|
215
|
+
const originalKey = Object.keys(this.ThaiAlphabetShift).find(
|
|
216
|
+
(key) => this.ThaiAlphabetShift[key] === currentChar
|
|
217
|
+
);
|
|
218
|
+
if (originalKey) {
|
|
219
|
+
key.textContent = originalKey;
|
|
220
|
+
key.dataset.key = originalKey;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
toggleShift() {
|
|
227
|
+
this.shiftActive = !this.shiftActive;
|
|
228
|
+
const shiftKey = document.querySelector('.key[data-key="Shift"]');
|
|
229
|
+
shiftKey.classList.toggle("active", this.shiftActive);
|
|
230
|
+
shiftKey.classList.toggle("bg-gray-400", this.shiftActive);
|
|
231
|
+
|
|
232
|
+
document.querySelectorAll(".key").forEach((key) => {
|
|
233
|
+
if (key.dataset.key.length === 1 && /[a-zA-Zก-๙]/.test(key.dataset.key)) {
|
|
234
|
+
// แสดงผลตัวพิมพ์ใหญ่หรือเล็กตามค่า Shift
|
|
235
|
+
key.textContent = this.shiftActive
|
|
236
|
+
? key.dataset.key.toUpperCase()
|
|
237
|
+
: key.dataset.key.toLowerCase();
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const keyboardKeys = document.querySelectorAll(".key:not([data-key='Shift'])");
|
|
242
|
+
keyboardKeys.forEach((key) => {
|
|
243
|
+
const currentChar = key.textContent.trim();
|
|
244
|
+
if (
|
|
245
|
+
this.shiftActive &&
|
|
246
|
+
this.currentLayout === "th" && // ตรวจสอบว่ากำลังใช้เลย์เอาต์ภาษาไทย
|
|
247
|
+
this.ThaiAlphabetShift[currentChar]
|
|
248
|
+
) {
|
|
249
|
+
key.textContent = this.ThaiAlphabetShift[currentChar]; // แสดงอักษรจาก shift
|
|
250
|
+
key.dataset.key = this.ThaiAlphabetShift[currentChar]; // อัปเดต dataset.key
|
|
251
|
+
} else if (
|
|
252
|
+
!this.shiftActive &&
|
|
253
|
+
this.currentLayout === "th" &&
|
|
254
|
+
Object.values(this.ThaiAlphabetShift).includes(currentChar)
|
|
255
|
+
) {
|
|
256
|
+
const originalKey = Object.keys(this.ThaiAlphabetShift).find(
|
|
257
|
+
(key) => this.ThaiAlphabetShift[key] === currentChar
|
|
258
|
+
);
|
|
259
|
+
if (originalKey) {
|
|
260
|
+
key.textContent = originalKey;
|
|
261
|
+
key.dataset.key = originalKey;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
ThaiAlphabetShift = {
|
|
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
|
+
insertText(text) {
|
|
318
|
+
const start = this.currentInput.selectionStart;
|
|
319
|
+
const end = this.currentInput.selectionEnd;
|
|
320
|
+
this.currentInput.value = this.currentInput.value.slice(0, start) + text + this.currentInput.value.slice(end);
|
|
321
|
+
this.currentInput.selectionStart = this.currentInput.selectionEnd = start + text.length;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
toggle() {
|
|
325
|
+
this.isVisible = !this.isVisible;
|
|
326
|
+
this.render();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
changeLayout(layout) {
|
|
330
|
+
this.currentLayout = layout;
|
|
331
|
+
this.render();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
shuffleArray(array) {
|
|
335
|
+
for (let i = array.length - 1; i > 0; i--) {
|
|
336
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
337
|
+
[array[i], array[j]] = [array[j], array[i]];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
scrambleKeyboard() {
|
|
342
|
+
const keys = document.querySelectorAll(
|
|
343
|
+
".key:not([data-key=backspace]):not([data-key='+']):not([data-key='-']):not([data-key='*']):not([data-key='/']):not([data-key='%']):not([data-key='=']):not([data-key='.']):not([data-key='00'])"
|
|
344
|
+
);
|
|
345
|
+
const numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
|
|
346
|
+
this.shuffleArray(numbers);
|
|
347
|
+
keys.forEach((key, index) => {
|
|
348
|
+
key.textContent = numbers[index];
|
|
349
|
+
key.dataset.key = numbers[index];
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
scrambleEnglishKeys() {
|
|
354
|
+
const keys = document.querySelectorAll(
|
|
355
|
+
".key:not([data-key='Space']):not([data-key='Backspace']):not([data-key='Caps']):not([data-key='Shift']):not([data-key='Enter']):not([data-key='Tab']):not([data-key='`']):not([data-key='1']):not([data-key='2']):not([data-key='3']):not([data-key='4']):not([data-key='5']):not([data-key='6']):not([data-key='7']):not([data-key='8']):not([data-key='9']):not([data-key='0']):not([data-key='-']):not([data-key='+']):not([data-key='='])"
|
|
356
|
+
);
|
|
357
|
+
const englishAlphabet = "abcdefghijklmnopqrstuvwxyz".split("");
|
|
358
|
+
this.shuffleArray(englishAlphabet);
|
|
359
|
+
keys.forEach((key, index) => {
|
|
360
|
+
key.textContent = englishAlphabet[index];
|
|
361
|
+
key.dataset.key = englishAlphabet[index];
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
scrambleThaiKeys() {
|
|
366
|
+
const keys = document.querySelectorAll(
|
|
367
|
+
".key:not([data-key='Backspace']):not([data-key='Caps']):not([data-key='Shift']):not([data-key='Enter']):not([data-key='Space'])"
|
|
368
|
+
);
|
|
369
|
+
const ThaiAlphabet = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮ".split("");
|
|
370
|
+
this.shuffleArray(ThaiAlphabet); // สับเปลี่ยนลำดับของตัวอักษร
|
|
371
|
+
|
|
372
|
+
keys.forEach((key, index) => {
|
|
373
|
+
// อัพเดต textContent และ dataset.key ให้ตรงกับค่าใหม่ที่สับเปลี่ยน
|
|
374
|
+
key.textContent = ThaiAlphabet[index];
|
|
375
|
+
key.dataset.key = ThaiAlphabet[index]; // อัพเดต dataset.key ด้วยค่าใหม่
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
// จัดการการลากคีย์บอร์ด
|
|
381
|
+
startDrag(event) {
|
|
382
|
+
this.isDragging = true;
|
|
383
|
+
this.offsetX = event.clientX - document.getElementById("keyboard").offsetLeft;
|
|
384
|
+
this.offsetY = event.clientY - document.getElementById("keyboard").offsetTop;
|
|
385
|
+
|
|
386
|
+
document.addEventListener("mousemove", this.drag.bind(this)); // Use bind to preserve `this` context
|
|
387
|
+
document.addEventListener("mouseup", () => {
|
|
388
|
+
this.isDragging = false;
|
|
389
|
+
document.removeEventListener("mousemove", this.drag.bind(this));
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
drag(event) {
|
|
394
|
+
if (this.isDragging) {
|
|
395
|
+
const keyboard = document.getElementById("keyboard");
|
|
396
|
+
keyboard.style.left = `${event.clientX - this.offsetX}px`;
|
|
397
|
+
keyboard.style.top = `${event.clientY - this.offsetY}px`;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
package/layouts.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const layouts = {
|
|
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']
|
|
8
|
+
],
|
|
9
|
+
th: [
|
|
10
|
+
['_', 'ๅ', '/', '-', 'ภ', 'ถ', 'ุ', 'ึ', 'ค', 'ต', 'จ', 'ข', 'ช', 'Backspace'],
|
|
11
|
+
['Tab', 'ๆ', 'ไ', 'ำ', 'พ', 'ะ', 'ั', 'ี', 'ร', 'น', 'ย', 'บ', 'ล', 'ฃ'],
|
|
12
|
+
['Caps', 'ฟ', 'ห', 'ก', 'ด', 'เ', '้', '่', 'า', 'ส', 'ว', 'ง', 'Enter'],
|
|
13
|
+
['Shift', 'ผ', 'ป', 'แ', 'อ', 'ิ', 'ื', 'ท', 'ม', 'ใ', 'ฝ', 'Shift'],
|
|
14
|
+
['Space']
|
|
15
|
+
],
|
|
16
|
+
numpad: [
|
|
17
|
+
["+", "-", "*", "/"],
|
|
18
|
+
["1", "2", "3", "%"],
|
|
19
|
+
["4", "5", "6", "."],
|
|
20
|
+
["7", "8", "9", "="],
|
|
21
|
+
["00", "0", "backspace"],
|
|
22
|
+
],
|
|
23
|
+
scNum : [
|
|
24
|
+
["+", "-", "*", "/"],
|
|
25
|
+
["1", "2", "3", "%"],
|
|
26
|
+
["4", "5", "6", "."],
|
|
27
|
+
["7", "8", "9", "="],
|
|
28
|
+
["00", "0", "backspace"],
|
|
29
|
+
],
|
|
30
|
+
thSc : [
|
|
31
|
+
["ก", "ข", "ฃ", "ค", "ฅ", "ฆ", "ง", "จ", "ฉ", "ช", "ซ", "ฌ", "Backspace"],
|
|
32
|
+
["ญ", "ฎ", "ฏ", "ฐ", "ฑ", "ฒ", "ณ", "ด", "ต", "ถ", "ท", "ธ", "น"],
|
|
33
|
+
["บ", "ป", "ผ", "ฝ", "พ", "ฟ", "ภ", "ม", "ย", "ร", "ฤ", "Enter"],
|
|
34
|
+
["ล", "ฦ", "ว", "ศ", "ษ", "ส", "ห", "ฬ", "อ", "ฮ"],
|
|
35
|
+
["Space"],
|
|
36
|
+
],
|
|
37
|
+
enSc: [
|
|
38
|
+
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "="],
|
|
39
|
+
["Tab", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "Backspace"],
|
|
40
|
+
["Caps", "a", "s", "d", "f", "g", "h", "j", "k", "l", "Enter"],
|
|
41
|
+
["Shift", "z", "x", "c", "v", "b", "n", "m", "Shift"],
|
|
42
|
+
["Space"],
|
|
43
|
+
],
|
|
44
|
+
};
|
package/main.js
ADDED
package/package.json
CHANGED
package/index.js
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
class Layout {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.activeInput = null;
|
|
4
|
-
this.isDragging = false;
|
|
5
|
-
this.offsetX = 0;
|
|
6
|
-
this.offsetY = 0;
|
|
7
|
-
this.isCapsLock = false;
|
|
8
|
-
this.isShift = false;
|
|
9
|
-
this.currentLanguage = "english";
|
|
10
|
-
this.encryptionKey = "1234567890123456";
|
|
11
|
-
|
|
12
|
-
this.initEventListeners();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
initEventListeners() {
|
|
16
|
-
document.querySelectorAll("input, textarea, form").forEach((element) => {
|
|
17
|
-
element.addEventListener("focus", (event) => {
|
|
18
|
-
event.stopImmediatePropagation();
|
|
19
|
-
this.activeInput = element;
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
24
|
-
document.querySelectorAll(".key").forEach((key) => {
|
|
25
|
-
key.addEventListener("click", (event) => {
|
|
26
|
-
if (key.classList.contains("capslock")) {
|
|
27
|
-
this.toggleCapsLock();
|
|
28
|
-
} else if (key.classList.contains("tab")) {
|
|
29
|
-
this.tab();
|
|
30
|
-
} else if (key.classList.contains("backspace")) {
|
|
31
|
-
this.backspace();
|
|
32
|
-
} else if (key.classList.contains("shift")) {
|
|
33
|
-
this.toggleShift();
|
|
34
|
-
} else if (key.classList.contains("enter")) {
|
|
35
|
-
this.toggleEnter();
|
|
36
|
-
} else if (key.classList.contains("toggle-lang")) {
|
|
37
|
-
this.switchLanguage();
|
|
38
|
-
} else {
|
|
39
|
-
this.handleKeyPress(key);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
document
|
|
45
|
-
.getElementById("login-button")
|
|
46
|
-
.addEventListener("click", this.login.bind(this));
|
|
47
|
-
document
|
|
48
|
-
.getElementById("toggleKeyboard")
|
|
49
|
-
.addEventListener("click", this.toggleKeyboard.bind(this));
|
|
50
|
-
document
|
|
51
|
-
.getElementById("switch-toggle")
|
|
52
|
-
.addEventListener("click", this.switchLanguage.bind(this));
|
|
53
|
-
document
|
|
54
|
-
.getElementById("numpad-toggle")
|
|
55
|
-
.addEventListener("click", this.numpad.bind(this));
|
|
56
|
-
document
|
|
57
|
-
.getElementById("scramble-toggle")
|
|
58
|
-
.addEventListener("click", this.scramble.bind(this));
|
|
59
|
-
document
|
|
60
|
-
.getElementById("scramble-toggle-thai")
|
|
61
|
-
.addEventListener("click", () => this.scrambleLanguage("thai"));
|
|
62
|
-
document
|
|
63
|
-
.getElementById("scramble-toggle-eng")
|
|
64
|
-
.addEventListener("click", () => this.scrambleLanguage("english"));
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
startDrag(event) {
|
|
69
|
-
this.isDragging = true;
|
|
70
|
-
this.offsetX = event.clientX - document.getElementById("keyboard").offsetLeft;
|
|
71
|
-
this.offsetY = event.clientY - document.getElementById("keyboard").offsetTop;
|
|
72
|
-
|
|
73
|
-
document.addEventListener("mousemove", drag);
|
|
74
|
-
document.addEventListener("mouseup", () => {
|
|
75
|
-
this.isDragging = false;
|
|
76
|
-
document.removeEventListener("mousemove", drag);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
drag(event) {
|
|
81
|
-
if (this.isDragging) {
|
|
82
|
-
const keyboard = document.getElementById("keyboard");
|
|
83
|
-
keyboard.style.left = `${event.clientX - offsetX}px`;
|
|
84
|
-
keyboard.style.top = `${event.clientY - offsetY}px`;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
toggleCapsLock() {
|
|
89
|
-
this.isCapsLock = !this.isCapsLock;
|
|
90
|
-
const capsLockKeys = document.querySelectorAll(".capslock");
|
|
91
|
-
capsLockKeys.forEach((key) => key.classList.toggle("caps-active"));
|
|
92
|
-
|
|
93
|
-
document.querySelectorAll(".key").forEach((key) => {
|
|
94
|
-
const normalText = key.getAttribute("data-normal");
|
|
95
|
-
const shiftedText = key.getAttribute("data-shifted");
|
|
96
|
-
|
|
97
|
-
if (this.isCapsLock) {
|
|
98
|
-
key.innerText = shiftedText || normalText.toUpperCase();
|
|
99
|
-
} else {
|
|
100
|
-
key.innerText = normalText;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
toggleShift() {
|
|
106
|
-
this.isShift = !this.isShift;
|
|
107
|
-
const shiftKeys = document.querySelectorAll(".shift");
|
|
108
|
-
shiftKeys.forEach((key) => key.classList.toggle("shift-active"));
|
|
109
|
-
|
|
110
|
-
document.querySelectorAll(".key").forEach((key) => {
|
|
111
|
-
const normalText = key.getAttribute("data-normal");
|
|
112
|
-
const shiftedText = key.getAttribute("data-shifted");
|
|
113
|
-
|
|
114
|
-
if (this.isShift) {
|
|
115
|
-
key.innerText = shiftedText || normalText.toUpperCase();
|
|
116
|
-
} else {
|
|
117
|
-
key.innerText = normalText;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
switchLanguage() {
|
|
123
|
-
this.currentLanguage =
|
|
124
|
-
this.currentLanguage === "english" ? "thai" : "english";
|
|
125
|
-
|
|
126
|
-
document.getElementById("english-keyboard").style.display =
|
|
127
|
-
this.currentLanguage === "english" ? "block" : "none";
|
|
128
|
-
document.getElementById("thai-keyboard").style.display =
|
|
129
|
-
this.currentLanguage === "thai" ? "block" : "none";
|
|
130
|
-
|
|
131
|
-
document.getElementById("numpad-keyboard").style.display = "none";
|
|
132
|
-
document.getElementById("scrambled-keyboard").style.display = "none";
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async login(event) {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
const username = document.getElementById("u___n___").value;
|
|
138
|
-
const password = document.getElementById("p___w___").value;
|
|
139
|
-
|
|
140
|
-
const encryptedPassword = this.encryptText(password);
|
|
141
|
-
|
|
142
|
-
const loginData = {
|
|
143
|
-
u___n___: username,
|
|
144
|
-
p___w___: encryptedPassword,
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const response = await fetch("/login", {
|
|
148
|
-
method: "POST",
|
|
149
|
-
headers: {
|
|
150
|
-
"Content-Type": "application/json",
|
|
151
|
-
},
|
|
152
|
-
body: JSON.stringify(loginData),
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const data = await response.json();
|
|
156
|
-
|
|
157
|
-
if (data.token) {
|
|
158
|
-
alert("เข้าสู่ระบบสำเร็จ");
|
|
159
|
-
localStorage.setItem("token", data.token);
|
|
160
|
-
location.reload();
|
|
161
|
-
} else {
|
|
162
|
-
alert(data.message || "เกิดข้อผิดพลาด");
|
|
163
|
-
location.reload();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
toggletap(event) {
|
|
168
|
-
const key = event.target;
|
|
169
|
-
key.style.backgroundColor = "#45a049";
|
|
170
|
-
|
|
171
|
-
setTimeout(() => {
|
|
172
|
-
key.style.backgroundColor = "#d3d3d3";
|
|
173
|
-
}, 100);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
numpad() {
|
|
177
|
-
const englishKeyboard = document.getElementById("english-keyboard");
|
|
178
|
-
const thaiKeyboard = document.getElementById("thai-keyboard");
|
|
179
|
-
const scrambledKeyboard = document.getElementById("scrambled-keyboard");
|
|
180
|
-
const numpadKeyboard = document.getElementById("numpad-keyboard");
|
|
181
|
-
const engScramble = document.getElementById("english-Scramble");
|
|
182
|
-
const thaiScramble = document.getElementById("thai-Scramble");
|
|
183
|
-
|
|
184
|
-
englishKeyboard.style.display = "none";
|
|
185
|
-
thaiKeyboard.style.display = "none";
|
|
186
|
-
scrambledKeyboard.style.display = "none";
|
|
187
|
-
thaiScramble.style.display = "none";
|
|
188
|
-
engScramble.style.display = "none";
|
|
189
|
-
|
|
190
|
-
if (numpadKeyboard) {
|
|
191
|
-
numpadKeyboard.style.display = "block";
|
|
192
|
-
} else {
|
|
193
|
-
alert("Numpad layout is not available");
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
scramble() {
|
|
198
|
-
const englishKeyboard = document.getElementById("english-keyboard");
|
|
199
|
-
const thaiKeyboard = document.getElementById("thai-keyboard");
|
|
200
|
-
const scrambledKeyboard = document.getElementById("scrambled-keyboard");
|
|
201
|
-
const numpadKeyboard = document.getElementById("numpad-keyboard");
|
|
202
|
-
const engScramble = document.getElementById("english-Scramble");
|
|
203
|
-
const thaiScramble = document.getElementById("thai-Scramble");
|
|
204
|
-
|
|
205
|
-
// ซ่อนคีย์บอร์ดทุกตัวที่ไม่ใช่ Scrambled
|
|
206
|
-
englishKeyboard.style.display = "none";
|
|
207
|
-
thaiKeyboard.style.display = "none";
|
|
208
|
-
numpadKeyboard.style.display = "none";
|
|
209
|
-
thaiScramble.style.display = "none";
|
|
210
|
-
engScramble.style.display = "none";
|
|
211
|
-
|
|
212
|
-
if (scrambledKeyboard) {
|
|
213
|
-
scrambledKeyboard.style.display = "block";
|
|
214
|
-
scrambleKeys(); // เรียกฟังก์ชันเพื่อสุ่มตัวเลขบนคีย์บอร์ด
|
|
215
|
-
} else {
|
|
216
|
-
alert("Scramble layout is not available");
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
scrambleKeys() {
|
|
221
|
-
// เลือกปุ่มทั้งหมดในคีย์บอร์ด "Scrambled" ยกเว้นปุ่ม backspace
|
|
222
|
-
const keys = document.querySelectorAll(
|
|
223
|
-
"#scrambled-keyboard .key:not(.backspace):not(.plus):not(.minus):not(.multiply):not(.divide):not(.modulo):not(.double-zero):not(.decimal):not(.equals)"
|
|
224
|
-
);
|
|
225
|
-
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
|
|
226
|
-
shuffleArray(numbers); // เรียงลำดับตัวเลขแบบสุ่ม
|
|
227
|
-
|
|
228
|
-
keys.forEach((key, index) => {
|
|
229
|
-
key.textContent = numbers[index];
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
scrambleLanguage(language) {
|
|
234
|
-
const englishKeyboard = document.getElementById("english-keyboard");
|
|
235
|
-
const thaiKeyboard = document.getElementById("thai-keyboard");
|
|
236
|
-
const scrambledKeyboard = document.getElementById("scrambled-keyboard");
|
|
237
|
-
const numpadKeyboard = document.getElementById("numpad-keyboard");
|
|
238
|
-
const engScramble = document.getElementById("english-Scramble");
|
|
239
|
-
const thaiScramble = document.getElementById("thai-Scramble");
|
|
240
|
-
|
|
241
|
-
if (language === "thai") {
|
|
242
|
-
englishKeyboard.style.display = "none";
|
|
243
|
-
thaiKeyboard.style.display = "none";
|
|
244
|
-
engScramble.style.display = "none";
|
|
245
|
-
numpadKeyboard.style.display = "none";
|
|
246
|
-
scrambledKeyboard.style.display = "none";
|
|
247
|
-
thaiScramble.style.display = "block";
|
|
248
|
-
scrambleThaiKeys(); // ฟังก์ชันสำหรับภาษาไทย
|
|
249
|
-
} else if (language === "english") {
|
|
250
|
-
englishKeyboard.style.display = "none";
|
|
251
|
-
thaiKeyboard.style.display = "none";
|
|
252
|
-
engScramble.style.display = "block";
|
|
253
|
-
numpadKeyboard.style.display = "none";
|
|
254
|
-
scrambledKeyboard.style.display = "none";
|
|
255
|
-
thaiScramble.style.display = "none";
|
|
256
|
-
scrambleEnglishKeys(); // ฟังก์ชันสำหรับภาษาอังกฤษ
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
scrambleEnglishKeys() {
|
|
261
|
-
const keys = document.querySelectorAll(
|
|
262
|
-
"#english-Scramble .key:not(.backspace):not(.capslock):not(.enter):not(.shift):not(.space-bar)"
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
const englishAlphabet = "abcdefghijklmnopqrstuvwxyz".split("");
|
|
266
|
-
shuffleArray(englishAlphabet);
|
|
267
|
-
|
|
268
|
-
keys.forEach((key, index) => {
|
|
269
|
-
if (index < englishAlphabet.length) {
|
|
270
|
-
key.textContent = englishAlphabet[index];
|
|
271
|
-
key.setAttribute("data-normal", englishAlphabet[index]);
|
|
272
|
-
key.setAttribute("data-shifted", englishAlphabet[index].toUpperCase());
|
|
273
|
-
} else {
|
|
274
|
-
key.textContent = "";
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
scrambleThaiKeys() {
|
|
280
|
-
const keys = document.querySelectorAll(
|
|
281
|
-
"#thai-Scramble .key:not(.backspace):not(.capslock):not(.enter):not(.shift):not(.space-bar)"
|
|
282
|
-
);
|
|
283
|
-
const thaiAlphabet = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮ".split(
|
|
284
|
-
""
|
|
285
|
-
);
|
|
286
|
-
shuffleArray(thaiAlphabet);
|
|
287
|
-
|
|
288
|
-
keys.forEach((key, index) => {
|
|
289
|
-
if (index < thaiAlphabet.length) {
|
|
290
|
-
key.textContent = thaiAlphabet[index];
|
|
291
|
-
key.setAttribute("data-normal", thaiAlphabet[index]);
|
|
292
|
-
key.setAttribute("data-shifted", thaiAlphabet[index]);
|
|
293
|
-
} else {
|
|
294
|
-
key.textContent = "";
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
shuffleArray(array) {
|
|
300
|
-
for (let i = array.length - 1; i > 0; i--) {
|
|
301
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
302
|
-
[array[i], array[j]] = [array[j], array[i]];
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
changeDropdownName(name) {
|
|
307
|
-
const dropdownButton = document.getElementById("dropdownButton");
|
|
308
|
-
dropdownButton.textContent = name;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
export default Layout;
|
package/layout.js
DELETED
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
class keyboard {
|
|
2
|
-
constructor() {
|
|
3
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
4
|
-
this.createKeyboardContainer();
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
createKeyboardContainer() {
|
|
9
|
-
const keyboardContainer = document.createElement("div");
|
|
10
|
-
keyboardContainer.className = "keyboard";
|
|
11
|
-
keyboardContainer.id = "keyboard";
|
|
12
|
-
keyboardContainer.onmousedown = this.startDrag;
|
|
13
|
-
|
|
14
|
-
keyboardContainer.innerHTML = this.generateKeyboardHTML();
|
|
15
|
-
document.body.appendChild(keyboardContainer);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
generateKeyboardHTML() {
|
|
19
|
-
return `
|
|
20
|
-
<div class="keyboard-container">
|
|
21
|
-
${this.generateDropdown()}
|
|
22
|
-
${this.generateEnglishKeyboard()}
|
|
23
|
-
${this.generateThaiKeyboard()}
|
|
24
|
-
${this.generateNumpadKeyboard()}
|
|
25
|
-
${this.generateScrambledKeyboard()}
|
|
26
|
-
${this.generateEnglishScramble()}
|
|
27
|
-
${this.generateThaiScramble()}
|
|
28
|
-
</div>
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
generateDropdown() {
|
|
33
|
-
return `
|
|
34
|
-
<div class="dropdown">
|
|
35
|
-
<button class="dropdown-button but" id="dropdownButton" style="color: black;">เลือกแป้นพิมพ์</button>
|
|
36
|
-
<div class="dropdown-content">
|
|
37
|
-
<button id="switch-toggle" onclick="changeDropdownName('Switch Language')">Switch Language</button>
|
|
38
|
-
<button id="numpad-toggle" onclick="changeDropdownName('Numpad Keyboard')">Numpad Keyboard</button>
|
|
39
|
-
<button id="scramble-toggle" onclick="changeDropdownName('Scramble Numpad')">Scramble Numpad</button>
|
|
40
|
-
<button id="scramble-toggle-thai" onclick="changeDropdownName('Thai Scramble')">Thai Scramble</button>
|
|
41
|
-
<button id="scramble-toggle-eng" onclick="changeDropdownName('English Scramble')">English Scramble</button>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
generateEnglishKeyboard() {
|
|
48
|
-
return `
|
|
49
|
-
<div id="english-keyboard" class="keyboard-layout">
|
|
50
|
-
<!-- English Keyboard Rows -->
|
|
51
|
-
<div class="keyboard-row">
|
|
52
|
-
<button class="key" data-normal="\`" data-shifted="%">\`</button>
|
|
53
|
-
<button class="key" data-normal="1" data-shifted="!">1</button>
|
|
54
|
-
<button class="key" data-normal="2" data-shifted="@">2</button>
|
|
55
|
-
<button class="key" data-normal="3" data-shifted="#">3</button>
|
|
56
|
-
<button class="key" data-normal="4" data-shifted="$">4</button>
|
|
57
|
-
<button class="key" data-normal="5" data-shifted="%">5</button>
|
|
58
|
-
<button class="key" data-normal="6" data-shifted="^">6</button>
|
|
59
|
-
<button class="key" data-normal="7" data-shifted="&">7</button>
|
|
60
|
-
<button class="key" data-normal="8" data-shifted="*">8</button>
|
|
61
|
-
<button class="key" data-normal="9" data-shifted="(">9</button>
|
|
62
|
-
<button class="key" data-normal="0" data-shifted=")">0</button>
|
|
63
|
-
<button class="key" data-normal="-" data-shifted="_">-</button>
|
|
64
|
-
<button class="key" data-normal="=" data-shifted="+">=</button>
|
|
65
|
-
<button class="key backspace">Backspace</button>
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<div class="keyboard-row">
|
|
69
|
-
<button class="key tab">Tab</button>
|
|
70
|
-
<button class="key" data-normal="q" data-shifted="Q">q</button>
|
|
71
|
-
<button class="key" data-normal="w" data-shifted="W">w</button>
|
|
72
|
-
<button class="key" data-normal="e" data-shifted="E">e</button>
|
|
73
|
-
<button class="key" data-normal="r" data-shifted="R">r</button>
|
|
74
|
-
<button class="key" data-normal="t" data-shifted="T">t</button>
|
|
75
|
-
<button class="key" data-normal="y" data-shifted="Y">y</button>
|
|
76
|
-
<button class="key" data-normal="u" data-shifted="U">u</button>
|
|
77
|
-
<button class="key" data-normal="i" data-shifted="I">i</button>
|
|
78
|
-
<button class="key" data-normal="o" data-shifted="O">o</button>
|
|
79
|
-
<button class="key" data-normal="p" data-shifted="P">p</button>
|
|
80
|
-
<button class="key" data-normal="[" data-shifted="{">[</button>
|
|
81
|
-
<button class="key" data-normal="]" data-shifted="}">]</button>
|
|
82
|
-
<button class="key" data-normal="\\" data-shifted="|">\\</button>
|
|
83
|
-
</div>
|
|
84
|
-
|
|
85
|
-
<div class="keyboard-row">
|
|
86
|
-
<button class="key capslock">CapsLk</button>
|
|
87
|
-
<button class="key" data-normal="a" data-shifted="A">a</button>
|
|
88
|
-
<button class="key" data-normal="s" data-shifted="S">s</button>
|
|
89
|
-
<button class="key" data-normal="d" data-shifted="D">d</button>
|
|
90
|
-
<button class="key" data-normal="f" data-shifted="F">f</button>
|
|
91
|
-
<button class="key" data-normal="g" data-shifted="G">g</button>
|
|
92
|
-
<button class="key" data-normal="h" data-shifted="H">h</button>
|
|
93
|
-
<button class="key" data-normal="j" data-shifted="J">j</button>
|
|
94
|
-
<button class="key" data-normal="k" data-shifted="K">k</button>
|
|
95
|
-
<button class="key" data-normal="l" data-shifted="L">l</button>
|
|
96
|
-
<button class="key" data-normal=";" data-shifted=":">;</button>
|
|
97
|
-
<button class="key" data-normal="'" data-shifted=""">'</button>
|
|
98
|
-
<button class="key enter" style="width: 90px; top:20%">Enter</button>
|
|
99
|
-
</div>
|
|
100
|
-
|
|
101
|
-
<div class="keyboard-row">
|
|
102
|
-
<button class="key shift" style="width: 120px;">Shift</button>
|
|
103
|
-
<button class="key" data-normal="z" data-shifted="Z">z</button>
|
|
104
|
-
<button class="key" data-normal="x" data-shifted="X">x</button>
|
|
105
|
-
<button class="key" data-normal="c" data-shifted="C">c</button>
|
|
106
|
-
<button class="key" data-normal="v" data-shifted="V">v</button>
|
|
107
|
-
<button class="key" data-normal="b" data-shifted="B">b</button>
|
|
108
|
-
<button class="key" data-normal="n" data-shifted="N">n</button>
|
|
109
|
-
<button class="key" data-normal="m" data-shifted="M">m</button>
|
|
110
|
-
<button class="key" data-normal="," data-shifted="<">,</button>
|
|
111
|
-
<button class="key" data-normal="." data-shifted=">">.</button>
|
|
112
|
-
<button class="key" data-normal="/" data-shifted="?">/</button>
|
|
113
|
-
<button class="key shift" style="width: 115px;">Shift</button>
|
|
114
|
-
</div>
|
|
115
|
-
|
|
116
|
-
<div class="keyboard-row">
|
|
117
|
-
<button class="key space-bar" data-normal=" " data-shifted=" "> </button>
|
|
118
|
-
</div>
|
|
119
|
-
</div>
|
|
120
|
-
`;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
generateThaiKeyboard() {
|
|
124
|
-
return `
|
|
125
|
-
<div id="thai-keyboard" class="keyboard-layout" style="display: none;">
|
|
126
|
-
<!-- Thai Keyboard Rows -->
|
|
127
|
-
<div class="keyboard-row">
|
|
128
|
-
<button class="key" data-normal="_" data-shifted="%">_</button>
|
|
129
|
-
<button class="key" data-normal="ๅ" data-shifted="+">ๅ</button>
|
|
130
|
-
<button class="key" data-normal="/" data-shifted="๑">/</button>
|
|
131
|
-
<button class="key" data-normal="-" data-shifted="๒">-</button>
|
|
132
|
-
<button class="key" data-normal="ภ" data-shifted="๓">ภ</button>
|
|
133
|
-
<button class="key" data-normal="ถ" data-shifted="๔">ถ</button>
|
|
134
|
-
<button class="key" data-normal="ุ" data-shifted="ู">ู</button>
|
|
135
|
-
<button class="key" data-normal="ึ" data-shifted="ฺ">฿</button>
|
|
136
|
-
<button class="key" data-normal="ค" data-shifted="๕">ค</button>
|
|
137
|
-
<button class="key" data-normal="ต" data-shifted="๖">ต</button>
|
|
138
|
-
<button class="key" data-normal="จ" data-shifted="๗">จ</button>
|
|
139
|
-
<button class="key" data-normal="ข" data-shifted="๘">ข</button>
|
|
140
|
-
<button class="key" data-normal="ช" data-shifted="๙">ช</button>
|
|
141
|
-
<button class="key backspace">Backspace</button>
|
|
142
|
-
</div>
|
|
143
|
-
|
|
144
|
-
<div class="keyboard-row">
|
|
145
|
-
<button class="key tab">Tab</button>
|
|
146
|
-
<button class="key" data-normal="ๆ" data-shifted="๐">ๆ</button>
|
|
147
|
-
<button class="key" data-normal="ไ" data-shifted=""">ไ</button>
|
|
148
|
-
<button class="key" data-normal="ำ" data-shifted="ฎ">ำ</button>
|
|
149
|
-
<button class="key" data-normal="พ" data-shifted="ฑ">พ</button>
|
|
150
|
-
<button class="key" data-normal="ะ" data-shifted="ธ">ะ</button>
|
|
151
|
-
<button class="key" data-normal="ั" data-shifted="ํ">ั</button>
|
|
152
|
-
<button class="key" data-normal="ี" data-shifted="๋">ี</button>
|
|
153
|
-
<button class="key" data-normal="ร" data-shifted="ณ">ร</button>
|
|
154
|
-
<button class="key" data-normal="น" data-shifted="ฯ">น</button>
|
|
155
|
-
<button class="key" data-normal="ย" data-shifted="ญ">ย</button>
|
|
156
|
-
<button class="key" data-normal="บ" data-shifted="ฐ">บ</button>
|
|
157
|
-
<button class="key" data-normal="ล" data-shifted=",">ล</button>
|
|
158
|
-
<button class="key" data-normal="ฃ" data-shifted="ฅ">ฃ</button>
|
|
159
|
-
</div>
|
|
160
|
-
|
|
161
|
-
<div class="keyboard-row">
|
|
162
|
-
<button class="key capslock">CapsLock</button>
|
|
163
|
-
<button class="key" data-normal="ฟ" data-shifted="ฤ">ฟ</button>
|
|
164
|
-
<button class="key" data-normal="ห" data-shifted="ฆ">ห</button>
|
|
165
|
-
<button class="key" data-normal="ก" data-shifted="ฏ">ก</button>
|
|
166
|
-
<button class="key" data-normal="ด" data-shifted="โ">ด</button>
|
|
167
|
-
<button class="key" data-normal="เ" data-shifted="ฌ">เ</button>
|
|
168
|
-
<button class="key" data-normal="้" data-shifted="็">้</button>
|
|
169
|
-
<button class="key" data-normal="่" data-shifted="๋">่</button>
|
|
170
|
-
<button class="key" data-normal="า" data-shifted="ษ">า</button>
|
|
171
|
-
<button class="key" data-normal="ส" data-shifted="ศ">ส</button>
|
|
172
|
-
<button class="key" data-normal="ว" data-shifted="ซ">ว</button>
|
|
173
|
-
<button class="key" data-normal="ง" data-shifted=".">ง</button>
|
|
174
|
-
<button class="key enter" style="width: 90px; top:20%">Enter</button>
|
|
175
|
-
</div>
|
|
176
|
-
|
|
177
|
-
<div class="keyboard-row">
|
|
178
|
-
<button class="key shift" style="width: 120px;">Shift</button>
|
|
179
|
-
<button class="key" data-normal="ผ" data-shifted="(">ผ</button>
|
|
180
|
-
<button class="key" data-normal="ป" data-shifted=")">ป</button>
|
|
181
|
-
<button class="key" data-normal="แ" data-shifted="ฉ">แ</button>
|
|
182
|
-
<button class="key" data-normal="อ" data-shifted="ฮ">อ</button>
|
|
183
|
-
<button class="key" data-normal="ิ" data-shifted="ฺ">ิ</button>
|
|
184
|
-
<button class="key" data-normal="ื" data-shifted="์">ื</button>
|
|
185
|
-
<button class="key" data-normal="ท" data-shifted="?">ท</button>
|
|
186
|
-
<button class="key" data-normal="ม" data-shifted="ฒ">ม</button>
|
|
187
|
-
<button class="key" data-normal="ใ" data-shifted="ฬ">ใ</button>
|
|
188
|
-
<button class="key" data-normal="ฝ" data-shifted="ฦ">ฝ</button>
|
|
189
|
-
<button class="key shift" style="width: 115px;">Shift</button>
|
|
190
|
-
</div>
|
|
191
|
-
|
|
192
|
-
<div class="keyboard-row">
|
|
193
|
-
<button class="key space-bar" data-normal=" " data-shifted=" "> </button>
|
|
194
|
-
</div>
|
|
195
|
-
</div>
|
|
196
|
-
`;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
generateNumpadKeyboard() {
|
|
200
|
-
return `
|
|
201
|
-
<div id="numpad-keyboard" class="keyboard-layout" style="display: none;">
|
|
202
|
-
<div class="keyboard-row">
|
|
203
|
-
<button class="key">+</button>
|
|
204
|
-
<button class="key">-</button>
|
|
205
|
-
<button class="key">*</button>
|
|
206
|
-
<button class="key">/</button>
|
|
207
|
-
</div>
|
|
208
|
-
<div class="keyboard-row">
|
|
209
|
-
<button class="key">1</button>
|
|
210
|
-
<button class="key">2</button>
|
|
211
|
-
<button class="key">3</button>
|
|
212
|
-
<button class="key">%</button>
|
|
213
|
-
</div>
|
|
214
|
-
|
|
215
|
-
<div class="keyboard-row">
|
|
216
|
-
<button class="key">4</button>
|
|
217
|
-
<button class="key">5</button>
|
|
218
|
-
<button class="key">6</button>
|
|
219
|
-
<button class="key">.</button>
|
|
220
|
-
</div>
|
|
221
|
-
|
|
222
|
-
<div class="keyboard-row">
|
|
223
|
-
<button class="key">7</button>
|
|
224
|
-
<button class="key">8</button>
|
|
225
|
-
<button class="key">9</button>
|
|
226
|
-
<button class="key">=</button>
|
|
227
|
-
</div>
|
|
228
|
-
|
|
229
|
-
<div class="keyboard-row">
|
|
230
|
-
<button class="key">00</button>
|
|
231
|
-
<button class="key">0</button>
|
|
232
|
-
<button class="key backspace" style="width: 90px;">Backspace</button>
|
|
233
|
-
</div>
|
|
234
|
-
</div>
|
|
235
|
-
`;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
generateScrambledKeyboard() {
|
|
239
|
-
return `
|
|
240
|
-
<div id="scrambled-keyboard" class="keyboard-layout" style="display: none;">
|
|
241
|
-
<!-- เพิ่มปุ่มสำหรับคีย์บอร์ด Scramble -->
|
|
242
|
-
<div class="keyboard-row">
|
|
243
|
-
<button class="key plus">+</button>
|
|
244
|
-
<button class="key minus">-</button>
|
|
245
|
-
<button class="key multiply">*</button>
|
|
246
|
-
<button class="key divide">/</button>
|
|
247
|
-
</div>
|
|
248
|
-
<div class="keyboard-row">
|
|
249
|
-
<button class="key">1</button>
|
|
250
|
-
<button class="key">2</button>
|
|
251
|
-
<button class="key">3</button>
|
|
252
|
-
<button class="key modulo">%</button>
|
|
253
|
-
</div>
|
|
254
|
-
|
|
255
|
-
<div class="keyboard-row">
|
|
256
|
-
<button class="key">4</button>
|
|
257
|
-
<button class="key">5</button>
|
|
258
|
-
<button class="key">6</button>
|
|
259
|
-
<button class="key decimal">.</button>
|
|
260
|
-
</div>
|
|
261
|
-
|
|
262
|
-
<div class="keyboard-row">
|
|
263
|
-
<button class="key">7</button>
|
|
264
|
-
<button class="key">8</button>
|
|
265
|
-
<button class="key">9</button>
|
|
266
|
-
<button class="key equals">=</button>
|
|
267
|
-
</div>
|
|
268
|
-
|
|
269
|
-
<div class="keyboard-row">
|
|
270
|
-
<button class="key double-zero">00</button>
|
|
271
|
-
<button class="key">0</button>
|
|
272
|
-
<button class="key backspace" style="width: 90px;">Backspace</button>
|
|
273
|
-
</div>
|
|
274
|
-
</div>
|
|
275
|
-
`;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
generateEnglishScramble() {
|
|
279
|
-
return `
|
|
280
|
-
<div id="english-Scramble" class="keyboard-layout" style="display: none;">
|
|
281
|
-
<!-- English Keyboard Rows -->
|
|
282
|
-
<div class="keyboard-row">
|
|
283
|
-
<button class="key" data-normal="q" data-shifted="Q">q</button>
|
|
284
|
-
<button class="key" data-normal="w" data-shifted="W">w</button>
|
|
285
|
-
<button class="key" data-normal="e" data-shifted="E">e</button>
|
|
286
|
-
<button class="key" data-normal="r" data-shifted="R">r</button>
|
|
287
|
-
<button class="key" data-normal="t" data-shifted="T">t</button>
|
|
288
|
-
<button class="key" data-normal="y" data-shifted="Y">y</button>
|
|
289
|
-
<button class="key" data-normal="u" data-shifted="U">u</button>
|
|
290
|
-
<button class="key" data-normal="i" data-shifted="I">i</button>
|
|
291
|
-
<button class="key" data-normal="o" data-shifted="O">o</button>
|
|
292
|
-
<button class="key" data-normal="p" data-shifted="P">p</button>
|
|
293
|
-
<button class="key backspace">Backspace</button>
|
|
294
|
-
</div>
|
|
295
|
-
|
|
296
|
-
<div class="keyboard-row">
|
|
297
|
-
<button class="key capslock">CapsLk</button>
|
|
298
|
-
<button class="key" data-normal="s" data-shifted="S">s</button>
|
|
299
|
-
<button class="key" data-normal="d" data-shifted="D">d</button>
|
|
300
|
-
<button class="key" data-normal="f" data-shifted="F">f</button>
|
|
301
|
-
<button class="key" data-normal="g" data-shifted="G">g</button>
|
|
302
|
-
<button class="key" data-normal="h" data-shifted="H">h</button>
|
|
303
|
-
<button class="key" data-normal="j" data-shifted="J">j</button>
|
|
304
|
-
<button class="key" data-normal="k" data-shifted="K">k</button>
|
|
305
|
-
<button class="key" data-normal="l" data-shifted="L">l</button>
|
|
306
|
-
<button class="key enter" style="width: 90px; top:20%">Enter</button>
|
|
307
|
-
</div>
|
|
308
|
-
|
|
309
|
-
<div class="keyboard-row">
|
|
310
|
-
<button class="key shift" style="width: 90px;">Shift</button>
|
|
311
|
-
<button class="key" data-normal="z" data-shifted="Z">z</button>
|
|
312
|
-
<button class="key" data-normal="x" data-shifted="X">x</button>
|
|
313
|
-
<button class="key" data-normal="c" data-shifted="C">c</button>
|
|
314
|
-
<button class="key" data-normal="v" data-shifted="V">v</button>
|
|
315
|
-
<button class="key" data-normal="b" data-shifted="B">b</button>
|
|
316
|
-
<button class="key" data-normal="n" data-shifted="N">n</button>
|
|
317
|
-
<button class="key" data-normal="m" data-shifted="M">m</button>
|
|
318
|
-
<button class="key" data-normal="a" data-shifted="A">m</button>
|
|
319
|
-
<button class="key shift" style="width: 100px;">Shift</button>
|
|
320
|
-
</div>
|
|
321
|
-
|
|
322
|
-
<div class="keyboard-row">
|
|
323
|
-
<button class="key space-bar" data-normal=" " data-shifted=" "> </button>
|
|
324
|
-
</div>
|
|
325
|
-
</div>
|
|
326
|
-
`;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
generateThaiScramble() {
|
|
330
|
-
return `
|
|
331
|
-
<div id="thai-Scramble" class="keyboard-layout" style="display: none;">
|
|
332
|
-
<!-- Thai Keyboard Rows -->
|
|
333
|
-
<div class="keyboard-row">
|
|
334
|
-
<button class="key" data-normal="ก" data-shifted="ก">ก</button>
|
|
335
|
-
<button class="key" data-normal="ข" data-shifted="ข">ข</button>
|
|
336
|
-
<button class="key" data-normal="ฃ" data-shifted="ฃ">ฃ</button>
|
|
337
|
-
<button class="key" data-normal="ค" data-shifted="ค">ค</button>
|
|
338
|
-
<button class="key" data-normal="ฅ" data-shifted="ฅ">ฅ</button>
|
|
339
|
-
<button class="key" data-normal="ฆ" data-shifted="ฆ">ฆ</button>
|
|
340
|
-
<button class="key" data-normal="ง" data-shifted="ง">ง</button>
|
|
341
|
-
<button class="key" data-normal="จ" data-shifted="จ">จ</button>
|
|
342
|
-
<button class="key" data-normal="ฉ" data-shifted="ฉ">ฉ</button>
|
|
343
|
-
<button class="key" data-normal="ช" data-shifted="ช">ช</button>
|
|
344
|
-
<button class="key" data-normal="ซ" data-shifted="ซ">ซ</button>
|
|
345
|
-
<button class="key" data-normal="ฌ" data-shifted="ฌ">ฌ</button>
|
|
346
|
-
<button class="key" data-normal="ญ" data-shifted="ญ">ญ</button>
|
|
347
|
-
<button class="key" data-normal="ฎ" data-shifted="ฎ">ฎ</button>
|
|
348
|
-
<button class="key backspace" style="width: 86px;">Backspace</button>
|
|
349
|
-
</div>
|
|
350
|
-
|
|
351
|
-
<div class="keyboard-row">
|
|
352
|
-
<button class="key" data-normal="ฏ" data-shifted="ฏ">ฏ</button>
|
|
353
|
-
<button class="key" data-normal="ฐ" data-shifted="ฐ">ฐ</button>
|
|
354
|
-
<button class="key" data-normal="ฑ" data-shifted="ฑ">ฑ</button>
|
|
355
|
-
<button class="key" data-normal="ฒ" data-shifted="ฒ">ฒ</button>
|
|
356
|
-
<button class="key" data-normal="ณ" data-shifted="ณ">ณ</button>
|
|
357
|
-
<button class="key" data-normal="ด" data-shifted="ด">ด</button>
|
|
358
|
-
<button class="key" data-normal="ต" data-shifted="ต">ต</button>
|
|
359
|
-
<button class="key" data-normal="ถ" data-shifted="ถ">ถ</button>
|
|
360
|
-
<button class="key" data-normal="ท" data-shifted="ท">ท</button>
|
|
361
|
-
<button class="key" data-normal="ธ" data-shifted="ธ">ธ</button>
|
|
362
|
-
<button class="key" data-normal="น" data-shifted="น">น</button>
|
|
363
|
-
<button class="key" data-normal="บ" data-shifted="บ">บ</button>
|
|
364
|
-
<button class="key" data-normal="ป" data-shifted="ป">ป</button>
|
|
365
|
-
<button class="key" data-normal="ผ" data-shifted="ผ">ผ</button>
|
|
366
|
-
<button class="key" data-normal="ฝ" data-shifted="ฝ">ฝ</button>
|
|
367
|
-
<button class="key" data-normal="พ" data-shifted="พ">พ</button>
|
|
368
|
-
</div>
|
|
369
|
-
|
|
370
|
-
<div class="keyboard-row">
|
|
371
|
-
<button class="key" data-normal="ฟ" data-shifted="ฟ">ฟ</button>
|
|
372
|
-
<button class="key" data-normal="ภ" data-shifted="ภ">ภ</button>
|
|
373
|
-
<button class="key" data-normal="ม" data-shifted="ม">ม</button>
|
|
374
|
-
<button class="key" data-normal="ย" data-shifted="ย">ย</button>
|
|
375
|
-
<button class="key" data-normal="ร" data-shifted="ร">ร</button>
|
|
376
|
-
<button class="key" data-normal="ฤ" data-shifted="ฤ">ฤ</button>
|
|
377
|
-
<button class="key" data-normal="ล" data-shifted="ล">ล</button>
|
|
378
|
-
<button class="key" data-normal="ฦ" data-shifted="ฦ">ฦ</button>
|
|
379
|
-
<button class="key" data-normal="ว" data-shifted="ว">ว</button>
|
|
380
|
-
<button class="key" data-normal="ศ" data-shifted="ศ">ศ</button>
|
|
381
|
-
<button class="key" data-normal="ษ" data-shifted="ษ">ษ</button>
|
|
382
|
-
<button class="key" data-normal="ส" data-shifted="ส">ส</button>
|
|
383
|
-
<button class="key" data-normal="ห" data-shifted="ห">ห</button>
|
|
384
|
-
<button class="key" data-normal="ฬ" data-shifted="ฬ">ฬ</button>
|
|
385
|
-
<button class="key" data-normal="อ" data-shifted="อ">อ</button>
|
|
386
|
-
<button class="key" data-normal="ฮ" data-shifted="ฮ">ฮ</button>
|
|
387
|
-
</div>
|
|
388
|
-
|
|
389
|
-
<div class="keyboard-row">
|
|
390
|
-
<button class="key space-bar" data-normal=" " data-shifted=" "> </button>
|
|
391
|
-
</div>
|
|
392
|
-
</div>
|
|
393
|
-
<script src="index.js"></script>
|
|
394
|
-
`;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
export default keyboard;
|