js_lis 1.0.5 → 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 -352
- package/main.js +4 -0
- package/package.json +1 -1
- package/keyboard.js +0 -514
|
@@ -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
CHANGED
|
@@ -1,352 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<button class="key" data-normal="r" data-shifted="R">r</button>
|
|
46
|
-
<button class="key" data-normal="t" data-shifted="T">t</button>
|
|
47
|
-
<button class="key" data-normal="y" data-shifted="Y">y</button>
|
|
48
|
-
<button class="key" data-normal="u" data-shifted="U">u</button>
|
|
49
|
-
<button class="key" data-normal="i" data-shifted="I">i</button>
|
|
50
|
-
<button class="key" data-normal="o" data-shifted="O">o</button>
|
|
51
|
-
<button class="key" data-normal="p" data-shifted="P">p</button>
|
|
52
|
-
<button class="key" data-normal="[" data-shifted="{">[</button>
|
|
53
|
-
<button class="key" data-normal="]" data-shifted="}">]</button>
|
|
54
|
-
<button class="key" data-normal="\\" data-shifted="|">\\</button>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<div class="keyboard-row">
|
|
58
|
-
<button class="key capslock">CapsLk</button>
|
|
59
|
-
<button class="key" data-normal="a" data-shifted="A">a</button>
|
|
60
|
-
<button class="key" data-normal="s" data-shifted="S">s</button>
|
|
61
|
-
<button class="key" data-normal="d" data-shifted="D">d</button>
|
|
62
|
-
<button class="key" data-normal="f" data-shifted="F">f</button>
|
|
63
|
-
<button class="key" data-normal="g" data-shifted="G">g</button>
|
|
64
|
-
<button class="key" data-normal="h" data-shifted="H">h</button>
|
|
65
|
-
<button class="key" data-normal="j" data-shifted="J">j</button>
|
|
66
|
-
<button class="key" data-normal="k" data-shifted="K">k</button>
|
|
67
|
-
<button class="key" data-normal="l" data-shifted="L">l</button>
|
|
68
|
-
<button class="key" data-normal=";" data-shifted=":">;</button>
|
|
69
|
-
<button class="key" data-normal="'" data-shifted=""">'</button>
|
|
70
|
-
<button class="key enter" style="width: 90px; top:20%">Enter</button>
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<div class="keyboard-row">
|
|
74
|
-
<button class="key shift" style="width: 120px;">Shift</button>
|
|
75
|
-
<button class="key" data-normal="z" data-shifted="Z">z</button>
|
|
76
|
-
<button class="key" data-normal="x" data-shifted="X">x</button>
|
|
77
|
-
<button class="key" data-normal="c" data-shifted="C">c</button>
|
|
78
|
-
<button class="key" data-normal="v" data-shifted="V">v</button>
|
|
79
|
-
<button class="key" data-normal="b" data-shifted="B">b</button>
|
|
80
|
-
<button class="key" data-normal="n" data-shifted="N">n</button>
|
|
81
|
-
<button class="key" data-normal="m" data-shifted="M">m</button>
|
|
82
|
-
<button class="key" data-normal="," data-shifted="<">,</button>
|
|
83
|
-
<button class="key" data-normal="." data-shifted=">">.</button>
|
|
84
|
-
<button class="key" data-normal="/" data-shifted="?">/</button>
|
|
85
|
-
<button class="key shift" style="width: 115px;">Shift</button>
|
|
86
|
-
</div>
|
|
87
|
-
|
|
88
|
-
<div class="keyboard-row">
|
|
89
|
-
<button class="key space-bar" data-normal=" " data-shifted=" "> </button>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
<div id="thai-keyboard" class="keyboard-layout" style="display: none;">
|
|
94
|
-
<!-- Thai Keyboard Rows -->
|
|
95
|
-
<div class="keyboard-row">
|
|
96
|
-
<button class="key" data-normal="_" data-shifted="%">_</button>
|
|
97
|
-
<button class="key" data-normal="ๅ" data-shifted="+">ๅ</button>
|
|
98
|
-
<button class="key" data-normal="/" data-shifted="๑">/</button>
|
|
99
|
-
<button class="key" data-normal="-" data-shifted="๒">-</button>
|
|
100
|
-
<button class="key" data-normal="ภ" data-shifted="๓">ภ</button>
|
|
101
|
-
<button class="key" data-normal="ถ" data-shifted="๔">ถ</button>
|
|
102
|
-
<button class="key" data-normal="ุ" data-shifted="ู">ู</button>
|
|
103
|
-
<button class="key" data-normal="ึ" data-shifted="ฺ">฿</button>
|
|
104
|
-
<button class="key" data-normal="ค" data-shifted="๕">ค</button>
|
|
105
|
-
<button class="key" data-normal="ต" data-shifted="๖">ต</button>
|
|
106
|
-
<button class="key" data-normal="จ" data-shifted="๗">จ</button>
|
|
107
|
-
<button class="key" data-normal="ข" data-shifted="๘">ข</button>
|
|
108
|
-
<button class="key" data-normal="ช" data-shifted="๙">ช</button>
|
|
109
|
-
<button class="key backspace">Backspace</button>
|
|
110
|
-
</div>
|
|
111
|
-
|
|
112
|
-
<div class="keyboard-row">
|
|
113
|
-
<button class="key tab">Tab</button>
|
|
114
|
-
<button class="key" data-normal="ๆ" data-shifted="๐">ๆ</button>
|
|
115
|
-
<button class="key" data-normal="ไ" data-shifted=""">ไ</button>
|
|
116
|
-
<button class="key" data-normal="ำ" data-shifted="ฎ">ำ</button>
|
|
117
|
-
<button class="key" data-normal="พ" data-shifted="ฑ">พ</button>
|
|
118
|
-
<button class="key" data-normal="ะ" data-shifted="ธ">ะ</button>
|
|
119
|
-
<button class="key" data-normal="ั" data-shifted="ํ">ั</button>
|
|
120
|
-
<button class="key" data-normal="ี" data-shifted="๋">ี</button>
|
|
121
|
-
<button class="key" data-normal="ร" data-shifted="ณ">ร</button>
|
|
122
|
-
<button class="key" data-normal="น" data-shifted="ฯ">น</button>
|
|
123
|
-
<button class="key" data-normal="ย" data-shifted="ญ">ย</button>
|
|
124
|
-
<button class="key" data-normal="บ" data-shifted="ฐ">บ</button>
|
|
125
|
-
<button class="key" data-normal="ล" data-shifted=",">ล</button>
|
|
126
|
-
<button class="key" data-normal="ฃ" data-shifted="ฅ">ฃ</button>
|
|
127
|
-
</div>
|
|
128
|
-
|
|
129
|
-
<div class="keyboard-row">
|
|
130
|
-
<button class="key capslock">CapsLock</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" data-normal="ง" data-shifted=".">ง</button>
|
|
142
|
-
<button class="key enter" style="width: 90px; top:20%">Enter</button>
|
|
143
|
-
</div>
|
|
144
|
-
|
|
145
|
-
<div class="keyboard-row">
|
|
146
|
-
<button class="key shift" style="width: 120px;">Shift</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 shift" style="width: 115px;">Shift</button>
|
|
158
|
-
</div>
|
|
159
|
-
|
|
160
|
-
<div class="keyboard-row">
|
|
161
|
-
<button class="key space-bar" data-normal=" " data-shifted=" "> </button>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
<div id="numpad-keyboard" class="keyboard-layout" style="display: none;">
|
|
166
|
-
<div class="keyboard-row">
|
|
167
|
-
<button class="key">+</button>
|
|
168
|
-
<button class="key">-</button>
|
|
169
|
-
<button class="key">*</button>
|
|
170
|
-
<button class="key">/</button>
|
|
171
|
-
</div>
|
|
172
|
-
<div class="keyboard-row">
|
|
173
|
-
<button class="key">1</button>
|
|
174
|
-
<button class="key">2</button>
|
|
175
|
-
<button class="key">3</button>
|
|
176
|
-
<button class="key">%</button>
|
|
177
|
-
</div>
|
|
178
|
-
|
|
179
|
-
<div class="keyboard-row">
|
|
180
|
-
<button class="key">4</button>
|
|
181
|
-
<button class="key">5</button>
|
|
182
|
-
<button class="key">6</button>
|
|
183
|
-
<button class="key">.</button>
|
|
184
|
-
</div>
|
|
185
|
-
|
|
186
|
-
<div class="keyboard-row">
|
|
187
|
-
<button class="key">7</button>
|
|
188
|
-
<button class="key">8</button>
|
|
189
|
-
<button class="key">9</button>
|
|
190
|
-
<button class="key">=</button>
|
|
191
|
-
</div>
|
|
192
|
-
|
|
193
|
-
<div class="keyboard-row">
|
|
194
|
-
<button class="key">00</button>
|
|
195
|
-
<button class="key">0</button>
|
|
196
|
-
<button class="key backspace" style="width: 90px;">Backspace</button>
|
|
197
|
-
</div>
|
|
198
|
-
</div>
|
|
199
|
-
|
|
200
|
-
<!-- คีย์บอร์ด Scramble -->
|
|
201
|
-
<div id="scrambled-keyboard" class="keyboard-layout" style="display: none;">
|
|
202
|
-
<!-- เพิ่มปุ่มสำหรับคีย์บอร์ด Scramble -->
|
|
203
|
-
<div class="keyboard-row">
|
|
204
|
-
<button class="key plus">+</button>
|
|
205
|
-
<button class="key minus">-</button>
|
|
206
|
-
<button class="key multiply">*</button>
|
|
207
|
-
<button class="key divide">/</button>
|
|
208
|
-
</div>
|
|
209
|
-
<div class="keyboard-row">
|
|
210
|
-
<button class="key">1</button>
|
|
211
|
-
<button class="key">2</button>
|
|
212
|
-
<button class="key">3</button>
|
|
213
|
-
<button class="key modulo">%</button>
|
|
214
|
-
</div>
|
|
215
|
-
|
|
216
|
-
<div class="keyboard-row">
|
|
217
|
-
<button class="key">4</button>
|
|
218
|
-
<button class="key">5</button>
|
|
219
|
-
<button class="key">6</button>
|
|
220
|
-
<button class="key decimal">.</button>
|
|
221
|
-
</div>
|
|
222
|
-
|
|
223
|
-
<div class="keyboard-row">
|
|
224
|
-
<button class="key">7</button>
|
|
225
|
-
<button class="key">8</button>
|
|
226
|
-
<button class="key">9</button>
|
|
227
|
-
<button class="key equals">=</button>
|
|
228
|
-
</div>
|
|
229
|
-
|
|
230
|
-
<div class="keyboard-row">
|
|
231
|
-
<button class="key double-zero">00</button>
|
|
232
|
-
<button class="key">0</button>
|
|
233
|
-
<button class="key backspace" style="width: 90px;">Backspace</button>
|
|
234
|
-
</div>
|
|
235
|
-
</div>
|
|
236
|
-
|
|
237
|
-
<div id="english-Scramble" class="keyboard-layout" style="display: none;">
|
|
238
|
-
<!-- English Keyboard Rows -->
|
|
239
|
-
<div class="keyboard-row">
|
|
240
|
-
<button class="key" data-normal="q" data-shifted="Q">q</button>
|
|
241
|
-
<button class="key" data-normal="w" data-shifted="W">w</button>
|
|
242
|
-
<button class="key" data-normal="e" data-shifted="E">e</button>
|
|
243
|
-
<button class="key" data-normal="r" data-shifted="R">r</button>
|
|
244
|
-
<button class="key" data-normal="t" data-shifted="T">t</button>
|
|
245
|
-
<button class="key" data-normal="y" data-shifted="Y">y</button>
|
|
246
|
-
<button class="key" data-normal="u" data-shifted="U">u</button>
|
|
247
|
-
<button class="key" data-normal="i" data-shifted="I">i</button>
|
|
248
|
-
<button class="key" data-normal="o" data-shifted="O">o</button>
|
|
249
|
-
<button class="key" data-normal="p" data-shifted="P">p</button>
|
|
250
|
-
<button class="key backspace">Backspace</button>
|
|
251
|
-
</div>
|
|
252
|
-
|
|
253
|
-
<div class="keyboard-row">
|
|
254
|
-
<button class="key capslock">CapsLk</button>
|
|
255
|
-
<button class="key" data-normal="s" data-shifted="S">s</button>
|
|
256
|
-
<button class="key" data-normal="d" data-shifted="D">d</button>
|
|
257
|
-
<button class="key" data-normal="f" data-shifted="F">f</button>
|
|
258
|
-
<button class="key" data-normal="g" data-shifted="G">g</button>
|
|
259
|
-
<button class="key" data-normal="h" data-shifted="H">h</button>
|
|
260
|
-
<button class="key" data-normal="j" data-shifted="J">j</button>
|
|
261
|
-
<button class="key" data-normal="k" data-shifted="K">k</button>
|
|
262
|
-
<button class="key" data-normal="l" data-shifted="L">l</button>
|
|
263
|
-
<button class="key enter" style="width: 90px; top:20%">Enter</button>
|
|
264
|
-
</div>
|
|
265
|
-
|
|
266
|
-
<div class="keyboard-row">
|
|
267
|
-
<button class="key shift" style="width: 90px;">Shift</button>
|
|
268
|
-
<button class="key" data-normal="z" data-shifted="Z">z</button>
|
|
269
|
-
<button class="key" data-normal="x" data-shifted="X">x</button>
|
|
270
|
-
<button class="key" data-normal="c" data-shifted="C">c</button>
|
|
271
|
-
<button class="key" data-normal="v" data-shifted="V">v</button>
|
|
272
|
-
<button class="key" data-normal="b" data-shifted="B">b</button>
|
|
273
|
-
<button class="key" data-normal="n" data-shifted="N">n</button>
|
|
274
|
-
<button class="key" data-normal="m" data-shifted="M">m</button>
|
|
275
|
-
<button class="key" data-normal="a" data-shifted="A">m</button>
|
|
276
|
-
<button class="key shift" style="width: 100px;">Shift</button>
|
|
277
|
-
</div>
|
|
278
|
-
|
|
279
|
-
<div class="keyboard-row">
|
|
280
|
-
<button class="key space-bar" data-normal=" " data-shifted=" "> </button>
|
|
281
|
-
</div>
|
|
282
|
-
</div>
|
|
283
|
-
|
|
284
|
-
<div id="thai-Scramble" class="keyboard-layout" style="display: none;">
|
|
285
|
-
<!-- Thai Keyboard Rows -->
|
|
286
|
-
<div class="keyboard-row">
|
|
287
|
-
<button class="key" data-normal="ก" data-shifted="ก">ก</button>
|
|
288
|
-
<button class="key" data-normal="ข" data-shifted="ข">ข</button>
|
|
289
|
-
<button class="key" data-normal="ฃ" data-shifted="ฃ">ฃ</button>
|
|
290
|
-
<button class="key" data-normal="ค" data-shifted="ค">ค</button>
|
|
291
|
-
<button class="key" data-normal="ฅ" data-shifted="ฅ">ฅ</button>
|
|
292
|
-
<button class="key" data-normal="ฆ" data-shifted="ฆ">ฆ</button>
|
|
293
|
-
<button class="key" data-normal="ง" data-shifted="ง">ง</button>
|
|
294
|
-
<button class="key" data-normal="จ" data-shifted="จ">จ</button>
|
|
295
|
-
<button class="key" data-normal="ฉ" data-shifted="ฉ">ฉ</button>
|
|
296
|
-
<button class="key" data-normal="ช" data-shifted="ช">ช</button>
|
|
297
|
-
<button class="key" data-normal="ซ" data-shifted="ซ">ซ</button>
|
|
298
|
-
<button class="key" data-normal="ฌ" data-shifted="ฌ">ฌ</button>
|
|
299
|
-
<button class="key" data-normal="ญ" data-shifted="ญ">ญ</button>
|
|
300
|
-
<button class="key" data-normal="ฎ" data-shifted="ฎ">ฎ</button>
|
|
301
|
-
<button class="key backspace" style="width: 86px;">Backspace</button>
|
|
302
|
-
</div>
|
|
303
|
-
|
|
304
|
-
<div class="keyboard-row">
|
|
305
|
-
<button class="key" data-normal="ฏ" data-shifted="ฏ">ฏ</button>
|
|
306
|
-
<button class="key" data-normal="ฐ" data-shifted="ฐ">ฐ</button>
|
|
307
|
-
<button class="key" data-normal="ฑ" data-shifted="ฑ">ฑ</button>
|
|
308
|
-
<button class="key" data-normal="ฒ" data-shifted="ฒ">ฒ</button>
|
|
309
|
-
<button class="key" data-normal="ณ" data-shifted="ณ">ณ</button>
|
|
310
|
-
<button class="key" data-normal="ด" data-shifted="ด">ด</button>
|
|
311
|
-
<button class="key" data-normal="ต" data-shifted="ต">ต</button>
|
|
312
|
-
<button class="key" data-normal="ถ" data-shifted="ถ">ถ</button>
|
|
313
|
-
<button class="key" data-normal="ท" data-shifted="ท">ท</button>
|
|
314
|
-
<button class="key" data-normal="ธ" data-shifted="ธ">ธ</button>
|
|
315
|
-
<button class="key" data-normal="น" data-shifted="น">น</button>
|
|
316
|
-
<button class="key" data-normal="บ" data-shifted="บ">บ</button>
|
|
317
|
-
<button class="key" data-normal="ป" data-shifted="ป">ป</button>
|
|
318
|
-
<button class="key" data-normal="ผ" data-shifted="ผ">ผ</button>
|
|
319
|
-
<button class="key" data-normal="ฝ" data-shifted="ฝ">ฝ</button>
|
|
320
|
-
<button class="key" data-normal="พ" data-shifted="พ">พ</button>
|
|
321
|
-
</div>
|
|
322
|
-
|
|
323
|
-
<div class="keyboard-row">
|
|
324
|
-
<button class="key" data-normal="ฟ" data-shifted="ฟ">ฟ</button>
|
|
325
|
-
<button class="key" data-normal="ภ" data-shifted="ภ">ภ</button>
|
|
326
|
-
<button class="key" data-normal="ม" data-shifted="ม">ม</button>
|
|
327
|
-
<button class="key" data-normal="ย" data-shifted="ย">ย</button>
|
|
328
|
-
<button class="key" data-normal="ร" data-shifted="ร">ร</button>
|
|
329
|
-
<button class="key" data-normal="ฤ" data-shifted="ฤ">ฤ</button>
|
|
330
|
-
<button class="key" data-normal="ล" data-shifted="ล">ล</button>
|
|
331
|
-
<button class="key" data-normal="ฦ" data-shifted="ฦ">ฦ</button>
|
|
332
|
-
<button class="key" data-normal="ว" data-shifted="ว">ว</button>
|
|
333
|
-
<button class="key" data-normal="ศ" data-shifted="ศ">ศ</button>
|
|
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
|
-
</div>
|
|
341
|
-
|
|
342
|
-
<div class="keyboard-row">
|
|
343
|
-
<button class="key space-bar" data-normal=" " data-shifted=" "> </button>
|
|
344
|
-
</div>
|
|
345
|
-
</div>
|
|
346
|
-
</div>
|
|
347
|
-
|
|
348
|
-
<script src="keyboard.js"></script>
|
|
349
|
-
`;
|
|
350
|
-
|
|
351
|
-
document.body.appendChild(keyboardContainer);
|
|
352
|
-
});
|
|
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/keyboard.js
DELETED
|
@@ -1,514 +0,0 @@
|
|
|
1
|
-
let activeInput = null;
|
|
2
|
-
let isDragging = false;
|
|
3
|
-
let offsetX = 0,
|
|
4
|
-
offsetY = 0;
|
|
5
|
-
let isCapsLock = false;
|
|
6
|
-
let isShift = false;
|
|
7
|
-
let currentLanguage = "english";
|
|
8
|
-
const encryptionKey = "1234567890123456";
|
|
9
|
-
|
|
10
|
-
// เพิ่ม event listener
|
|
11
|
-
document.querySelectorAll("input, textarea, form").forEach((element) => {
|
|
12
|
-
element.addEventListener("focus", (event) => {
|
|
13
|
-
event.stopImmediatePropagation();
|
|
14
|
-
activeInput = element;
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// แสดง-ซ่อนคีย์บอร์ด
|
|
19
|
-
function toggleKeyboard() {
|
|
20
|
-
const keyboard = document.getElementById("keyboard");
|
|
21
|
-
keyboard.style.display = keyboard.style.display === "flex" ? "none" : "flex";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function encryptText(text) {
|
|
25
|
-
return CryptoJS.AES.encrypt(text, encryptionKey).toString();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function handleKeyPress(keyElement) {
|
|
29
|
-
if (activeInput) {
|
|
30
|
-
let keyToAdd;
|
|
31
|
-
if (isShift) {
|
|
32
|
-
keyToAdd =
|
|
33
|
-
keyElement.getAttribute("data-shifted") ||
|
|
34
|
-
keyElement.innerText.toUpperCase();
|
|
35
|
-
} else if (isCapsLock) {
|
|
36
|
-
keyToAdd =
|
|
37
|
-
keyElement.getAttribute("data-shifted") ||
|
|
38
|
-
keyElement.innerText.toUpperCase();
|
|
39
|
-
} else {
|
|
40
|
-
keyToAdd = keyElement.getAttribute("data-normal") || keyElement.innerText;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// เข้ารหัสข้อความที่กด
|
|
44
|
-
const encryptedKey = encryptText(keyToAdd);
|
|
45
|
-
|
|
46
|
-
// เพิ่มข้อความที่เข้ารหัสลงใน input
|
|
47
|
-
activeInput.value += keyToAdd;
|
|
48
|
-
|
|
49
|
-
activeInput.setAttribute("data-encrypted-value", encryptedKey);
|
|
50
|
-
|
|
51
|
-
if (isShift && !isCapsLock) {
|
|
52
|
-
toggleShift();
|
|
53
|
-
}
|
|
54
|
-
// console.log("Encrypted input: ", activeInput.getAttribute("data-encrypted-value"));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function toggleCapsLock() {
|
|
59
|
-
isCapsLock = !isCapsLock;
|
|
60
|
-
const capsLockKeys = document.querySelectorAll(".capslock");
|
|
61
|
-
capsLockKeys.forEach((key) => key.classList.toggle("caps-active"));
|
|
62
|
-
|
|
63
|
-
document.querySelectorAll(".key").forEach((key) => {
|
|
64
|
-
const normalText = key.getAttribute("data-normal");
|
|
65
|
-
const shiftedText = key.getAttribute("data-shifted");
|
|
66
|
-
|
|
67
|
-
if (isCapsLock) {
|
|
68
|
-
if (shiftedText) {
|
|
69
|
-
key.innerText = shiftedText;
|
|
70
|
-
} else if (normalText && normalText.match(/[a-zA-Z]/)) {
|
|
71
|
-
key.innerText = normalText.toUpperCase();
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
if (normalText) {
|
|
75
|
-
key.innerText = normalText;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function toggleShift() {
|
|
82
|
-
isShift = !isShift;
|
|
83
|
-
const shiftKeys = document.querySelectorAll(".shift");
|
|
84
|
-
shiftKeys.forEach((key) => key.classList.toggle("shift-active"));
|
|
85
|
-
|
|
86
|
-
document.querySelectorAll(".key").forEach((key) => {
|
|
87
|
-
const normalText = key.getAttribute("data-normal");
|
|
88
|
-
const shiftedText = key.getAttribute("data-shifted");
|
|
89
|
-
|
|
90
|
-
if (isShift) {
|
|
91
|
-
if (shiftedText) {
|
|
92
|
-
key.innerText = shiftedText;
|
|
93
|
-
} else if (normalText && normalText.match(/[a-zA-Z]/)) {
|
|
94
|
-
key.innerText = normalText.toUpperCase();
|
|
95
|
-
}
|
|
96
|
-
} else {
|
|
97
|
-
if (normalText) {
|
|
98
|
-
key.innerText = normalText;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function backspace() {
|
|
105
|
-
if (activeInput && activeInput.value.length > 0) {
|
|
106
|
-
activeInput.value = activeInput.value.slice(0, -1);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function Tab() {
|
|
111
|
-
if (activeInput) {
|
|
112
|
-
let start = activeInput.selectionStart;
|
|
113
|
-
let end = activeInput.selectionEnd;
|
|
114
|
-
|
|
115
|
-
activeInput.value = activeInput.value.substring(0, start) + " " + activeInput.value.substring(end);
|
|
116
|
-
|
|
117
|
-
activeInput.selectionStart = activeInput.selectionEnd = start + 4;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// จัดการการลากคีย์บอร์ด
|
|
122
|
-
function startDrag(event) {
|
|
123
|
-
isDragging = true;
|
|
124
|
-
offsetX = event.clientX - document.getElementById("keyboard").offsetLeft;
|
|
125
|
-
offsetY = event.clientY - document.getElementById("keyboard").offsetTop;
|
|
126
|
-
|
|
127
|
-
document.addEventListener("mousemove", drag);
|
|
128
|
-
document.addEventListener("mouseup", () => {
|
|
129
|
-
isDragging = false;
|
|
130
|
-
document.removeEventListener("mousemove", drag);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function drag(event) {
|
|
135
|
-
if (isDragging) {
|
|
136
|
-
const keyboard = document.getElementById("keyboard");
|
|
137
|
-
keyboard.style.left = `${event.clientX - offsetX}px`;
|
|
138
|
-
keyboard.style.top = `${event.clientY - offsetY}px`;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function switchLanguage() {
|
|
143
|
-
const numpadKeyboard = document.getElementById("numpad-keyboard");
|
|
144
|
-
const scrambledKeyboard = document.getElementById("scrambled-keyboard");
|
|
145
|
-
const engScramble = document.getElementById("english-Scramble");
|
|
146
|
-
const thaiScramble = document.getElementById("thai-Scramble");
|
|
147
|
-
|
|
148
|
-
// สลับค่า currentLanguage
|
|
149
|
-
currentLanguage = currentLanguage === "english" ? "thai" : "english";
|
|
150
|
-
|
|
151
|
-
// แสดงคีย์บอร์ดตามภาษา
|
|
152
|
-
document.getElementById("english-keyboard").style.display =
|
|
153
|
-
currentLanguage === "english" ? "block" : "none";
|
|
154
|
-
document.getElementById("thai-keyboard").style.display =
|
|
155
|
-
currentLanguage === "thai" ? "block" : "none";
|
|
156
|
-
|
|
157
|
-
// ซ่อนคีย์บอร์ดอื่นๆ
|
|
158
|
-
numpadKeyboard.style.display = "none";
|
|
159
|
-
scrambledKeyboard.style.display = "none";
|
|
160
|
-
thaiScramble.style.display = "none";
|
|
161
|
-
engScramble.style.display = "none";
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
async function login(event) {
|
|
165
|
-
event.preventDefault();
|
|
166
|
-
|
|
167
|
-
// ดึงค่าที่เข้ารหัสจากฟอร์ม
|
|
168
|
-
const Username = document.getElementById("u___n___").value;
|
|
169
|
-
const Password = document.getElementById("p___w___").value;
|
|
170
|
-
|
|
171
|
-
// เข้ารหัสข้อมูลก่อนส่งไปยังเซิร์ฟเวอร์
|
|
172
|
-
// const encryptedu___n___ = encryptText(encryptedUsername);
|
|
173
|
-
const encryptedp___w___ = encryptText(Password);
|
|
174
|
-
|
|
175
|
-
const loginData = {
|
|
176
|
-
u___n___: Username,
|
|
177
|
-
p___w___: encryptedp___w___,
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
// ส่งข้อมูลที่เข้ารหัสไปยังเซิร์ฟเวอร์
|
|
181
|
-
const response = await fetch("https://login-gxrh.onrender.com/login", {
|
|
182
|
-
method: 'POST',
|
|
183
|
-
headers: {
|
|
184
|
-
'Content-Type': 'application/json',
|
|
185
|
-
},
|
|
186
|
-
body: JSON.stringify(loginData),
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const data = await response.json();
|
|
190
|
-
|
|
191
|
-
if (data.token) {
|
|
192
|
-
alert("เข้าสู่ระบบสำเร็จ");
|
|
193
|
-
localStorage.setItem("token", data.token);
|
|
194
|
-
location.reload();
|
|
195
|
-
} else {
|
|
196
|
-
alert(data.message || "เกิดข้อผิดพลาด");
|
|
197
|
-
location.reload();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// ปลี่ยนสีพื้นหลัง
|
|
202
|
-
function toggletap(event) {
|
|
203
|
-
const key = event.target;
|
|
204
|
-
key.style.backgroundColor = "#45a049";
|
|
205
|
-
|
|
206
|
-
setTimeout(() => {
|
|
207
|
-
key.style.backgroundColor = "#d3d3d3";
|
|
208
|
-
}, 100);
|
|
209
|
-
// console.log("Tap function");
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function toggleEnter(event) {
|
|
213
|
-
// ตรวจสอบว่าเป็นการกดปุ่ม Enter
|
|
214
|
-
if (activeInput.value === "Enter") {
|
|
215
|
-
// ป้องกันการส่งฟอร์มที่เกิดจากการกด Enter
|
|
216
|
-
event.preventDefault();
|
|
217
|
-
|
|
218
|
-
// เช็คว่า activeInput มีค่าและเป็นประเภท INPUT
|
|
219
|
-
if (activeInput && activeInput.tagName === "INPUT") {
|
|
220
|
-
// ส่งฟอร์มเมื่อกด Enter
|
|
221
|
-
activeInput.form.submit();
|
|
222
|
-
// console.log("Form submitted using Enter.");
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function Numpad() {
|
|
228
|
-
const englishKeyboard = document.getElementById("english-keyboard");
|
|
229
|
-
const thaiKeyboard = document.getElementById("thai-keyboard");
|
|
230
|
-
const scrambledKeyboard = document.getElementById("scrambled-keyboard");
|
|
231
|
-
const numpadKeyboard = document.getElementById("numpad-keyboard");
|
|
232
|
-
const engScramble = document.getElementById("english-Scramble");
|
|
233
|
-
const thaiScramble = document.getElementById("thai-Scramble");
|
|
234
|
-
|
|
235
|
-
englishKeyboard.style.display = "none";
|
|
236
|
-
thaiKeyboard.style.display = "none";
|
|
237
|
-
scrambledKeyboard.style.display = "none";
|
|
238
|
-
thaiScramble.style.display = "none";
|
|
239
|
-
engScramble.style.display = "none";
|
|
240
|
-
|
|
241
|
-
if (numpadKeyboard) {
|
|
242
|
-
numpadKeyboard.style.display = "block";
|
|
243
|
-
} else {
|
|
244
|
-
alert("Numpad layout is not available");
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function Scramble() {
|
|
249
|
-
const englishKeyboard = document.getElementById("english-keyboard");
|
|
250
|
-
const thaiKeyboard = document.getElementById("thai-keyboard");
|
|
251
|
-
const scrambledKeyboard = document.getElementById("scrambled-keyboard");
|
|
252
|
-
const numpadKeyboard = document.getElementById("numpad-keyboard");
|
|
253
|
-
const engScramble = document.getElementById("english-Scramble");
|
|
254
|
-
const thaiScramble = document.getElementById("thai-Scramble");
|
|
255
|
-
|
|
256
|
-
// ซ่อนคีย์บอร์ดทุกตัวที่ไม่ใช่ Scrambled
|
|
257
|
-
englishKeyboard.style.display = "none";
|
|
258
|
-
thaiKeyboard.style.display = "none";
|
|
259
|
-
numpadKeyboard.style.display = "none";
|
|
260
|
-
thaiScramble.style.display = "none";
|
|
261
|
-
engScramble.style.display = "none";
|
|
262
|
-
|
|
263
|
-
if (scrambledKeyboard) {
|
|
264
|
-
scrambledKeyboard.style.display = "block";
|
|
265
|
-
scrambleKeys(); // เรียกฟังก์ชันเพื่อสุ่มตัวเลขบนคีย์บอร์ด
|
|
266
|
-
} else {
|
|
267
|
-
alert("Scramble layout is not available");
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function scrambleKeys() {
|
|
272
|
-
// เลือกปุ่มทั้งหมดในคีย์บอร์ด "Scrambled" ยกเว้นปุ่ม backspace
|
|
273
|
-
const keys = document.querySelectorAll(
|
|
274
|
-
"#scrambled-keyboard .key:not(.backspace):not(.plus):not(.minus):not(.multiply):not(.divide):not(.modulo):not(.double-zero):not(.decimal):not(.equals)"
|
|
275
|
-
);
|
|
276
|
-
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
|
|
277
|
-
shuffleArray(numbers); // เรียงลำดับตัวเลขแบบสุ่ม
|
|
278
|
-
|
|
279
|
-
keys.forEach((key, index) => {
|
|
280
|
-
key.textContent = numbers[index];
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// ฟังก์ชัน scramble สำหรับภาษาไทยและภาษาอังกฤษ
|
|
285
|
-
function scrambleLanguage(language) {
|
|
286
|
-
const englishKeyboard = document.getElementById("english-keyboard");
|
|
287
|
-
const thaiKeyboard = document.getElementById("thai-keyboard");
|
|
288
|
-
const scrambledKeyboard = document.getElementById("scrambled-keyboard");
|
|
289
|
-
const numpadKeyboard = document.getElementById("numpad-keyboard");
|
|
290
|
-
const engScramble = document.getElementById("english-Scramble");
|
|
291
|
-
const thaiScramble = document.getElementById("thai-Scramble");
|
|
292
|
-
|
|
293
|
-
if (language === "thai") {
|
|
294
|
-
englishKeyboard.style.display = "none";
|
|
295
|
-
thaiKeyboard.style.display = "none";
|
|
296
|
-
engScramble.style.display = "none";
|
|
297
|
-
numpadKeyboard.style.display = "none";
|
|
298
|
-
scrambledKeyboard.style.display = "none";
|
|
299
|
-
thaiScramble.style.display = "block";
|
|
300
|
-
scrambleThaiKeys(); // ฟังก์ชันสำหรับภาษาไทย
|
|
301
|
-
} else if (language === "english") {
|
|
302
|
-
englishKeyboard.style.display = "none";
|
|
303
|
-
thaiKeyboard.style.display = "none";
|
|
304
|
-
engScramble.style.display = "block";
|
|
305
|
-
numpadKeyboard.style.display = "none";
|
|
306
|
-
scrambledKeyboard.style.display = "none";
|
|
307
|
-
thaiScramble.style.display = "none";
|
|
308
|
-
scrambleEnglishKeys(); // ฟังก์ชันสำหรับภาษาอังกฤษ
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// ฟังก์ชัน scramble สำหรับคีย์บอร์ดภาษาอังกฤษ
|
|
313
|
-
function scrambleEnglishKeys() {
|
|
314
|
-
const keys = document.querySelectorAll(
|
|
315
|
-
"#english-Scramble .key:not(.backspace):not(.capslock):not(.enter):not(.shift):not(.space-bar)"
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
const englishAlphabet = "abcdefghijklmnopqrstuvwxyz".split("");
|
|
319
|
-
shuffleArray(englishAlphabet);
|
|
320
|
-
|
|
321
|
-
keys.forEach((key, index) => {
|
|
322
|
-
if (index < englishAlphabet.length) {
|
|
323
|
-
key.textContent = englishAlphabet[index];
|
|
324
|
-
key.setAttribute("data-normal", englishAlphabet[index]);
|
|
325
|
-
key.setAttribute("data-shifted", englishAlphabet[index].toUpperCase());
|
|
326
|
-
} else {
|
|
327
|
-
key.textContent = "";
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// ฟังก์ชัน scramble สำหรับคีย์บอร์ดภาษาไทย
|
|
333
|
-
function scrambleThaiKeys() {
|
|
334
|
-
const keys = document.querySelectorAll(
|
|
335
|
-
"#thai-Scramble .key:not(.backspace):not(.capslock):not(.enter):not(.shift):not(.space-bar)"
|
|
336
|
-
);
|
|
337
|
-
const thaiAlphabet = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮ".split(
|
|
338
|
-
""
|
|
339
|
-
);
|
|
340
|
-
shuffleArray(thaiAlphabet);
|
|
341
|
-
|
|
342
|
-
keys.forEach((key, index) => {
|
|
343
|
-
if (index < thaiAlphabet.length) {
|
|
344
|
-
key.textContent = thaiAlphabet[index];
|
|
345
|
-
key.setAttribute("data-normal", thaiAlphabet[index]);
|
|
346
|
-
key.setAttribute("data-shifted", thaiAlphabet[index]);
|
|
347
|
-
} else {
|
|
348
|
-
key.textContent = "";
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// ฟังก์ชันเพื่อสับเปลี่ยนตัวอักษร
|
|
354
|
-
function shuffleArray(array) {
|
|
355
|
-
for (let i = array.length - 1; i > 0; i--) {
|
|
356
|
-
const j = Math.floor(Math.random() * (i + 1));
|
|
357
|
-
[array[i], array[j]] = [array[j], array[i]];
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function changeDropdownName(name) {
|
|
362
|
-
const dropdownButton = document.getElementById("dropdownButton");
|
|
363
|
-
dropdownButton.textContent = name;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
367
|
-
document.querySelectorAll(".key").forEach((key) => {
|
|
368
|
-
key.addEventListener("click", (event) => {
|
|
369
|
-
if (key.classList.contains("capslock")) {
|
|
370
|
-
toggleCapsLock();
|
|
371
|
-
} else if (key.classList.contains("tab")) {
|
|
372
|
-
Tab();
|
|
373
|
-
} else if (key.classList.contains("backspace")) {
|
|
374
|
-
backspace();
|
|
375
|
-
} else if (key.classList.contains("shift")) {
|
|
376
|
-
toggleShift();
|
|
377
|
-
} else if (key.classList.contains("enter")) {
|
|
378
|
-
toggleEnter();
|
|
379
|
-
} else if (key.classList.contains("toggle-lang")) {
|
|
380
|
-
switchLanguage();
|
|
381
|
-
} else {
|
|
382
|
-
handleKeyPress(key);
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
const loginButton = document.getElementById("login-button");
|
|
388
|
-
const toggleKeyboards = document.getElementById("toggleKeyboard");
|
|
389
|
-
|
|
390
|
-
loginButton.addEventListener("click", login);
|
|
391
|
-
toggleKeyboards.addEventListener("click", toggleKeyboard);
|
|
392
|
-
|
|
393
|
-
document
|
|
394
|
-
.getElementById("switch-toggle")
|
|
395
|
-
.addEventListener("click", switchLanguage);
|
|
396
|
-
document.getElementById("numpad-toggle").addEventListener("click", Numpad);
|
|
397
|
-
document
|
|
398
|
-
.getElementById("scramble-toggle")
|
|
399
|
-
.addEventListener("click", Scramble);
|
|
400
|
-
document
|
|
401
|
-
.getElementById("scramble-toggle-thai")
|
|
402
|
-
.addEventListener("click", () => scrambleLanguage("thai"));
|
|
403
|
-
document
|
|
404
|
-
.getElementById("scramble-toggle-eng")
|
|
405
|
-
.addEventListener("click", () => scrambleLanguage("english"));
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
/*
|
|
409
|
-
// ฟังก์ชันหลักในการป้องกันการจับภาพหน้าจอในเบราว์เซอร์
|
|
410
|
-
function preventScreenCapture() {
|
|
411
|
-
const overrideFunction = (target, method, handler) => {
|
|
412
|
-
if (target && target[method]) {
|
|
413
|
-
const original = target[method];
|
|
414
|
-
target[method] = function (...args) {
|
|
415
|
-
handler();
|
|
416
|
-
return Promise.reject("Screen capture blocked.");
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
// ตรวจสอบความพร้อมใช้งานของ navigator.mediaDevices และ getDisplayMedia
|
|
422
|
-
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
423
|
-
// ป้องกันการใช้งาน getDisplayMedia
|
|
424
|
-
overrideFunction(navigator.mediaDevices, 'getDisplayMedia', () => {
|
|
425
|
-
console.log('Screen capture attempt detected via getDisplayMedia!');
|
|
426
|
-
showBlackScreen(true);
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// ตรวจสอบความพร้อมใช้งานของ navigator.mediaDevices และ getUserMedia
|
|
431
|
-
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
432
|
-
// ป้องกันการใช้งาน getUserMedia
|
|
433
|
-
overrideFunction(navigator.mediaDevices, 'getUserMedia', () => {
|
|
434
|
-
console.log('Screen capture attempt detected via getUserMedia!');
|
|
435
|
-
showBlackScreen(true);
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// ป้องกันคีย์ลัด PrintScreen, Win+Shift+S และอื่นๆ
|
|
440
|
-
document.addEventListener('keyup', (event) => {
|
|
441
|
-
const encryptedText = CryptoJS.AES.encrypt(event.key, encryptionKey).toString();
|
|
442
|
-
console.log("ข้อความที่เข้ารหัส:", encryptedText);
|
|
443
|
-
|
|
444
|
-
// ถอดรหัสข้อความ
|
|
445
|
-
const bytes = CryptoJS.AES.decrypt(encryptedText, encryptionKey);
|
|
446
|
-
const decryptedText = bytes.toString(CryptoJS.enc.Utf8);
|
|
447
|
-
console.log("ข้อความที่ถอดรหัส:", decryptedText);
|
|
448
|
-
// console.log('Key pressed:', event.key);
|
|
449
|
-
if (event.key === 'PrintScreen' || (event.key === 'S' && event.shiftKey && event.metaKey)) {
|
|
450
|
-
console.log('Blocked PrintScreen or Win+Shift+S key.');
|
|
451
|
-
event.preventDefault();
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
// ตรวจจับการใช้งาน screen capture ของ third-party logger
|
|
456
|
-
if (navigator.mediaDevices) {
|
|
457
|
-
const originalGetUserMedia = navigator.mediaDevices.getUserMedia;
|
|
458
|
-
navigator.mediaDevices.getUserMedia = (constraints) => {
|
|
459
|
-
if (constraints && constraints.video && constraints.video.mediaSource === 'screen') {
|
|
460
|
-
console.warn('Screen capture attempt detected!');
|
|
461
|
-
return Promise.reject("Screen capture blocked.");
|
|
462
|
-
}
|
|
463
|
-
return originalGetUserMedia.call(navigator.mediaDevices, constraints);
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// ฟังก์ชันเพื่อแสดงหน้าจอสีดำ
|
|
469
|
-
function showBlackScreen(autoClose = false) {
|
|
470
|
-
const blackScreen = document.createElement('div');
|
|
471
|
-
blackScreen.style.position = 'fixed';
|
|
472
|
-
blackScreen.style.top = 0;
|
|
473
|
-
blackScreen.style.left = 0;
|
|
474
|
-
blackScreen.style.width = '100%';
|
|
475
|
-
blackScreen.style.height = '100%';
|
|
476
|
-
blackScreen.style.backgroundColor = '#000';
|
|
477
|
-
blackScreen.style.zIndex = '9999';
|
|
478
|
-
blackScreen.style.display = 'flex';
|
|
479
|
-
blackScreen.style.alignItems = 'center';
|
|
480
|
-
blackScreen.style.justifyContent = 'center';
|
|
481
|
-
blackScreen.style.color = '#FFF';
|
|
482
|
-
blackScreen.style.fontSize = '24px';
|
|
483
|
-
blackScreen.textContent = 'Screen capture blocked!';
|
|
484
|
-
|
|
485
|
-
document.body.appendChild(blackScreen);
|
|
486
|
-
|
|
487
|
-
if (autoClose) {
|
|
488
|
-
setTimeout(() => {
|
|
489
|
-
blackScreen.remove();
|
|
490
|
-
}, 3000);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
// เรียกใช้งานฟังก์ชัน
|
|
495
|
-
preventScreenCapture();
|
|
496
|
-
// preventKeyLogger();
|
|
497
|
-
|
|
498
|
-
// สร้าง Timer เพื่อตรวจสอบการทำงานเป็นระยะ
|
|
499
|
-
function createTimer(interval, callback) {
|
|
500
|
-
return setInterval(callback, interval);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function clearTimer(timerId) {
|
|
504
|
-
clearInterval(timerId);
|
|
505
|
-
} // ตัวอย่างการใช้งาน Timer
|
|
506
|
-
|
|
507
|
-
const screenCaptureTimer = createTimer(1000, () => {
|
|
508
|
-
console.log('Timer ticked - Checking screen capture status');
|
|
509
|
-
// เพิ่มฟังก์ชันการตรวจจับหรือจัดการเหตุการณ์ที่ต้องการ
|
|
510
|
-
preventScreenCapture(); // เรียกใช้งานฟังก์ชันการป้องกันการจับภาพหน้าจอ
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
// ยกเลิก Timer หลังจาก 10 วินาที
|
|
514
|
-
setTimeout(() => clearTimer(screenCaptureTimer), 10000);*/
|