@andy.ian/dsh-homing 2.1.7 → 2.1.8
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/lib/vendor/vnc.bundle.js +159 -1
- package/lib/vnc-app.js +79 -1
- package/lib/vnc-boot.js +1 -1
- package/lib/vnc-keyboard.mjs +92 -0
- package/package.json +1 -1
package/lib/vendor/vnc.bundle.js
CHANGED
|
@@ -14095,6 +14095,94 @@ RFB.cursors = {
|
|
|
14095
14095
|
}
|
|
14096
14096
|
};
|
|
14097
14097
|
|
|
14098
|
+
// D:/deepseek/dsh-homing/plugin/lib/vnc-keyboard.mjs
|
|
14099
|
+
var SPECIAL_KEYS = Object.freeze({
|
|
14100
|
+
Backspace: 65288,
|
|
14101
|
+
Tab: 65289,
|
|
14102
|
+
Enter: 65293,
|
|
14103
|
+
Escape: 65307,
|
|
14104
|
+
Delete: 65535
|
|
14105
|
+
});
|
|
14106
|
+
var SYMBOL_CODES = {
|
|
14107
|
+
" ": "Space",
|
|
14108
|
+
"-": "Minus",
|
|
14109
|
+
"=": "Equal",
|
|
14110
|
+
"[": "BracketLeft",
|
|
14111
|
+
"]": "BracketRight",
|
|
14112
|
+
"\\": "Backslash",
|
|
14113
|
+
";": "Semicolon",
|
|
14114
|
+
"'": "Quote",
|
|
14115
|
+
"`": "Backquote",
|
|
14116
|
+
",": "Comma",
|
|
14117
|
+
".": "Period",
|
|
14118
|
+
"/": "Slash"
|
|
14119
|
+
};
|
|
14120
|
+
var SHIFTED_SYMBOLS = {
|
|
14121
|
+
"!": "1",
|
|
14122
|
+
"@": "2",
|
|
14123
|
+
"#": "3",
|
|
14124
|
+
"$": "4",
|
|
14125
|
+
"%": "5",
|
|
14126
|
+
"^": "6",
|
|
14127
|
+
"&": "7",
|
|
14128
|
+
"*": "8",
|
|
14129
|
+
"(": "9",
|
|
14130
|
+
")": "0",
|
|
14131
|
+
"_": "-",
|
|
14132
|
+
"+": "=",
|
|
14133
|
+
"{": "[",
|
|
14134
|
+
"}": "]",
|
|
14135
|
+
"|": "\\",
|
|
14136
|
+
":": ";",
|
|
14137
|
+
'"': "'",
|
|
14138
|
+
"<": ",",
|
|
14139
|
+
">": ".",
|
|
14140
|
+
"?": "/",
|
|
14141
|
+
"~": "`"
|
|
14142
|
+
};
|
|
14143
|
+
function letterCode(letter) {
|
|
14144
|
+
return "Key" + letter.toUpperCase();
|
|
14145
|
+
}
|
|
14146
|
+
function digitCode(digit) {
|
|
14147
|
+
return "Digit" + digit;
|
|
14148
|
+
}
|
|
14149
|
+
function charToKey(char) {
|
|
14150
|
+
if (typeof char !== "string" || char.length === 0) return null;
|
|
14151
|
+
if (char === "\n" || char === "\r") return { keysym: SPECIAL_KEYS.Enter, code: "Enter", shift: false };
|
|
14152
|
+
if (char === "\b") return { keysym: SPECIAL_KEYS.Backspace, code: "Backspace", shift: false };
|
|
14153
|
+
if (char === " ") return { keysym: 32, code: "Space", shift: false };
|
|
14154
|
+
if (char === " ") return { keysym: SPECIAL_KEYS.Tab, code: "Tab", shift: false };
|
|
14155
|
+
if (SHIFTED_SYMBOLS[char]) {
|
|
14156
|
+
const base = SHIFTED_SYMBOLS[char];
|
|
14157
|
+
return { keysym: base.codePointAt(0), code: symbolCode(base), shift: true };
|
|
14158
|
+
}
|
|
14159
|
+
if (/^[a-z]$/u.test(char)) {
|
|
14160
|
+
return { keysym: char.codePointAt(0), code: letterCode(char), shift: false };
|
|
14161
|
+
}
|
|
14162
|
+
if (/^[A-Z]$/u.test(char)) {
|
|
14163
|
+
return { keysym: char.toLowerCase().codePointAt(0), code: letterCode(char), shift: true };
|
|
14164
|
+
}
|
|
14165
|
+
if (/^[0-9]$/u.test(char)) {
|
|
14166
|
+
return { keysym: char.codePointAt(0), code: digitCode(char), shift: false };
|
|
14167
|
+
}
|
|
14168
|
+
if (SYMBOL_CODES[char]) {
|
|
14169
|
+
return { keysym: char.codePointAt(0), code: SYMBOL_CODES[char], shift: false };
|
|
14170
|
+
}
|
|
14171
|
+
return null;
|
|
14172
|
+
}
|
|
14173
|
+
function symbolCode(char) {
|
|
14174
|
+
if (SYMBOL_CODES[char]) return SYMBOL_CODES[char];
|
|
14175
|
+
if (/^[0-9]$/u.test(char)) return digitCode(char);
|
|
14176
|
+
if (/^[a-z]$/u.test(char)) return letterCode(char);
|
|
14177
|
+
return "Unidentified";
|
|
14178
|
+
}
|
|
14179
|
+
function inputTypeToKey(inputType) {
|
|
14180
|
+
if (inputType === "deleteContentBackward") return { keysym: SPECIAL_KEYS.Backspace, code: "Backspace", shift: false };
|
|
14181
|
+
if (inputType === "deleteContentForward") return { keysym: SPECIAL_KEYS.Delete, code: "Delete", shift: false };
|
|
14182
|
+
if (inputType === "insertLineBreak" || inputType === "insertParagraph") return { keysym: SPECIAL_KEYS.Enter, code: "Enter", shift: false };
|
|
14183
|
+
return null;
|
|
14184
|
+
}
|
|
14185
|
+
|
|
14098
14186
|
// D:/deepseek/dsh-homing/plugin/lib/vnc-app.js
|
|
14099
14187
|
var statusEl = document.getElementById("status");
|
|
14100
14188
|
var passwordEl = document.getElementById("password");
|
|
@@ -14443,6 +14531,72 @@ async function rotateDesktop(mode) {
|
|
|
14443
14531
|
setStatus("\u5207\u6362\u5931\u8D25\uFF1A" + (error?.message ?? error), "bad");
|
|
14444
14532
|
}
|
|
14445
14533
|
}
|
|
14534
|
+
var keyboardInput = null;
|
|
14535
|
+
function focusKeyboard() {
|
|
14536
|
+
if (!keyboardInput) return;
|
|
14537
|
+
try {
|
|
14538
|
+
keyboardInput.focus({ preventScroll: true });
|
|
14539
|
+
setStatus("\u952E\u76D8\u5DF2\u6253\u5F00\uFF0C\u53EF\u76F4\u63A5\u8F93\u5165\uFF08\u8F93\u5165\u5185\u5BB9\u4F1A\u8F6C\u53D1\u5230\u7535\u8111\uFF09", "ok");
|
|
14540
|
+
} catch {
|
|
14541
|
+
}
|
|
14542
|
+
}
|
|
14543
|
+
function sendMappedKey(key) {
|
|
14544
|
+
if (!rfb || !key) return;
|
|
14545
|
+
try {
|
|
14546
|
+
if (key.shift) rfb.sendKey(KEYS.shift, "ShiftLeft", true);
|
|
14547
|
+
rfb.sendKey(key.keysym, key.code || "Unidentified", true);
|
|
14548
|
+
rfb.sendKey(key.keysym, key.code || "Unidentified", false);
|
|
14549
|
+
if (key.shift) rfb.sendKey(KEYS.shift, "ShiftLeft", false);
|
|
14550
|
+
} catch {
|
|
14551
|
+
}
|
|
14552
|
+
}
|
|
14553
|
+
function setupMobileKeyboard() {
|
|
14554
|
+
if (keyboardInput) return;
|
|
14555
|
+
const input = document.createElement("textarea");
|
|
14556
|
+
input.setAttribute("autocapitalize", "off");
|
|
14557
|
+
input.setAttribute("autocomplete", "off");
|
|
14558
|
+
input.setAttribute("autocorrect", "off");
|
|
14559
|
+
input.setAttribute("spellcheck", "false");
|
|
14560
|
+
input.setAttribute("aria-hidden", "true");
|
|
14561
|
+
input.style.cssText = "position:fixed;left:0;bottom:0;width:1px;height:1px;opacity:0.01;border:0;padding:0;margin:0;resize:none;z-index:2147483647;font-size:16px;background:transparent;color:transparent";
|
|
14562
|
+
const clear = () => {
|
|
14563
|
+
try {
|
|
14564
|
+
input.value = "";
|
|
14565
|
+
} catch {
|
|
14566
|
+
}
|
|
14567
|
+
};
|
|
14568
|
+
input.addEventListener("beforeinput", (event) => {
|
|
14569
|
+
event.preventDefault();
|
|
14570
|
+
const mapped = inputTypeToKey(event.inputType);
|
|
14571
|
+
if (mapped) {
|
|
14572
|
+
sendMappedKey(mapped);
|
|
14573
|
+
clear();
|
|
14574
|
+
return;
|
|
14575
|
+
}
|
|
14576
|
+
if (event.data) {
|
|
14577
|
+
for (const char of event.data) sendMappedKey(charToKey(char));
|
|
14578
|
+
clear();
|
|
14579
|
+
}
|
|
14580
|
+
});
|
|
14581
|
+
input.addEventListener("keydown", (event) => {
|
|
14582
|
+
const specials = {
|
|
14583
|
+
Backspace: SPECIAL_KEYS.Backspace,
|
|
14584
|
+
Enter: SPECIAL_KEYS.Enter,
|
|
14585
|
+
Tab: SPECIAL_KEYS.Tab,
|
|
14586
|
+
Escape: SPECIAL_KEYS.Escape,
|
|
14587
|
+
Delete: SPECIAL_KEYS.Delete
|
|
14588
|
+
};
|
|
14589
|
+
const keysym = specials[event.key];
|
|
14590
|
+
if (keysym) {
|
|
14591
|
+
event.preventDefault();
|
|
14592
|
+
sendMappedKey({ keysym, code: event.key, shift: false });
|
|
14593
|
+
clear();
|
|
14594
|
+
}
|
|
14595
|
+
});
|
|
14596
|
+
input.addEventListener("input", clear);
|
|
14597
|
+
document.body.appendChild(input);
|
|
14598
|
+
keyboardInput = input;
|
|
14599
|
+
}
|
|
14446
14600
|
function setupToolbar() {
|
|
14447
14601
|
if (document.getElementById("vnc-toolbar")) return;
|
|
14448
14602
|
const bar = document.createElement("div");
|
|
@@ -14472,11 +14626,13 @@ function setupToolbar() {
|
|
|
14472
14626
|
autoBtn,
|
|
14473
14627
|
button("\u5173\u95ED\u7A97\u53E3", () => pickWindowAction("close")),
|
|
14474
14628
|
button("\u9000\u51FA\u7A0B\u5E8F", () => pickWindowAction("kill")),
|
|
14629
|
+
button("\u952E\u76D8", () => focusKeyboard()),
|
|
14475
14630
|
button("Ctrl+Alt+Del", () => {
|
|
14476
14631
|
try {
|
|
14477
14632
|
if (rfb && typeof rfb.sendCtrlAltDel === "function") {
|
|
14478
14633
|
rfb.sendCtrlAltDel();
|
|
14479
|
-
setStatus("\u5DF2\u53D1\u9001 Ctrl+Alt+Del\uFF0C\
|
|
14634
|
+
setStatus("\u5DF2\u53D1\u9001 Ctrl+Alt+Del\uFF0C\u952E\u76D8\u5DF2\u5F39\u51FA\uFF0C\u8F93\u5165 PIN \u5373\u53EF", "ok");
|
|
14635
|
+
setTimeout(focusKeyboard, 300);
|
|
14480
14636
|
} else {
|
|
14481
14637
|
setStatus("\u5F53\u524D\u8FDE\u63A5\u4E0D\u652F\u6301\u53D1\u9001 Ctrl+Alt+Del", "bad");
|
|
14482
14638
|
}
|
|
@@ -14498,6 +14654,7 @@ function markClick(event) {
|
|
|
14498
14654
|
lastClickAt = Date.now();
|
|
14499
14655
|
clickBaseForeground = lastForeground;
|
|
14500
14656
|
pendingForeground = null;
|
|
14657
|
+
if (event && event.pointerType && event.pointerType !== "mouse") focusKeyboard();
|
|
14501
14658
|
}
|
|
14502
14659
|
canvasOfGuard();
|
|
14503
14660
|
function canvasOfGuard() {
|
|
@@ -14593,6 +14750,7 @@ window.addEventListener("pagehide", () => {
|
|
|
14593
14750
|
}
|
|
14594
14751
|
}
|
|
14595
14752
|
});
|
|
14753
|
+
setupMobileKeyboard();
|
|
14596
14754
|
setupToolbar();
|
|
14597
14755
|
function autoConnect() {
|
|
14598
14756
|
if (autoTried) return;
|
package/lib/vnc-app.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - 自动切换:点击后若弹出新窗口,自动把视图切到那个窗口
|
|
9
9
|
*/
|
|
10
10
|
import RFB from './vendor/novnc/core/rfb.js'
|
|
11
|
+
import { charToKey, inputTypeToKey, SPECIAL_KEYS } from './vnc-keyboard.mjs'
|
|
11
12
|
|
|
12
13
|
const statusEl = document.getElementById('status')
|
|
13
14
|
const passwordEl = document.getElementById('password')
|
|
@@ -416,6 +417,77 @@ async function rotateDesktop(mode) {
|
|
|
416
417
|
}
|
|
417
418
|
}
|
|
418
419
|
|
|
420
|
+
let keyboardInput = null
|
|
421
|
+
|
|
422
|
+
/** 弹出手机软键盘(必须是用户手势里调用) */
|
|
423
|
+
function focusKeyboard() {
|
|
424
|
+
if (!keyboardInput) return
|
|
425
|
+
try {
|
|
426
|
+
keyboardInput.focus({ preventScroll: true })
|
|
427
|
+
setStatus('键盘已打开,可直接输入(输入内容会转发到电脑)', 'ok')
|
|
428
|
+
} catch { /* 忽略 */ }
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function sendMappedKey(key) {
|
|
432
|
+
if (!rfb || !key) return
|
|
433
|
+
try {
|
|
434
|
+
if (key.shift) rfb.sendKey(KEYS.shift, 'ShiftLeft', true)
|
|
435
|
+
rfb.sendKey(key.keysym, key.code || 'Unidentified', true)
|
|
436
|
+
rfb.sendKey(key.keysym, key.code || 'Unidentified', false)
|
|
437
|
+
if (key.shift) rfb.sendKey(KEYS.shift, 'ShiftLeft', false)
|
|
438
|
+
} catch { /* 忽略 */ }
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* 手机软键盘桥:
|
|
443
|
+
* canvas 不是输入框,点它不会弹键盘;这里放一个 1px 隐藏 textarea,
|
|
444
|
+
* 把手机键盘的字符/退格/回车转换成 VNC 按键事件。
|
|
445
|
+
*/
|
|
446
|
+
function setupMobileKeyboard() {
|
|
447
|
+
if (keyboardInput) return
|
|
448
|
+
const input = document.createElement('textarea')
|
|
449
|
+
input.setAttribute('autocapitalize', 'off')
|
|
450
|
+
input.setAttribute('autocomplete', 'off')
|
|
451
|
+
input.setAttribute('autocorrect', 'off')
|
|
452
|
+
input.setAttribute('spellcheck', 'false')
|
|
453
|
+
input.setAttribute('aria-hidden', 'true')
|
|
454
|
+
input.style.cssText = 'position:fixed;left:0;bottom:0;width:1px;height:1px;opacity:0.01;border:0;padding:0;margin:0;resize:none;z-index:2147483647;font-size:16px;background:transparent;color:transparent'
|
|
455
|
+
const clear = () => { try { input.value = '' } catch { /* 忽略 */ } }
|
|
456
|
+
|
|
457
|
+
input.addEventListener('beforeinput', (event) => {
|
|
458
|
+
event.preventDefault()
|
|
459
|
+
const mapped = inputTypeToKey(event.inputType)
|
|
460
|
+
if (mapped) {
|
|
461
|
+
sendMappedKey(mapped)
|
|
462
|
+
clear()
|
|
463
|
+
return
|
|
464
|
+
}
|
|
465
|
+
if (event.data) {
|
|
466
|
+
for (const char of event.data) sendMappedKey(charToKey(char))
|
|
467
|
+
clear()
|
|
468
|
+
}
|
|
469
|
+
})
|
|
470
|
+
input.addEventListener('keydown', (event) => {
|
|
471
|
+
const specials = {
|
|
472
|
+
Backspace: SPECIAL_KEYS.Backspace,
|
|
473
|
+
Enter: SPECIAL_KEYS.Enter,
|
|
474
|
+
Tab: SPECIAL_KEYS.Tab,
|
|
475
|
+
Escape: SPECIAL_KEYS.Escape,
|
|
476
|
+
Delete: SPECIAL_KEYS.Delete,
|
|
477
|
+
}
|
|
478
|
+
const keysym = specials[event.key]
|
|
479
|
+
if (keysym) {
|
|
480
|
+
event.preventDefault()
|
|
481
|
+
sendMappedKey({ keysym, code: event.key, shift: false })
|
|
482
|
+
clear()
|
|
483
|
+
}
|
|
484
|
+
})
|
|
485
|
+
input.addEventListener('input', clear)
|
|
486
|
+
|
|
487
|
+
document.body.appendChild(input)
|
|
488
|
+
keyboardInput = input
|
|
489
|
+
}
|
|
490
|
+
|
|
419
491
|
function setupToolbar() {
|
|
420
492
|
if (document.getElementById('vnc-toolbar')) return
|
|
421
493
|
const bar = document.createElement('div')
|
|
@@ -444,11 +516,14 @@ function setupToolbar() {
|
|
|
444
516
|
autoBtn,
|
|
445
517
|
button('关闭窗口', () => pickWindowAction('close')),
|
|
446
518
|
button('退出程序', () => pickWindowAction('kill')),
|
|
519
|
+
button('键盘', () => focusKeyboard()),
|
|
447
520
|
button('Ctrl+Alt+Del', () => {
|
|
448
521
|
try {
|
|
449
522
|
if (rfb && typeof rfb.sendCtrlAltDel === 'function') {
|
|
450
523
|
rfb.sendCtrlAltDel()
|
|
451
|
-
setStatus('已发送 Ctrl+Alt+Del
|
|
524
|
+
setStatus('已发送 Ctrl+Alt+Del,键盘已弹出,输入 PIN 即可', 'ok')
|
|
525
|
+
// 在用户手势中立即聚焦隐藏输入框,手机浏览器才允许弹软键盘
|
|
526
|
+
setTimeout(focusKeyboard, 300)
|
|
452
527
|
} else {
|
|
453
528
|
setStatus('当前连接不支持发送 Ctrl+Alt+Del', 'bad')
|
|
454
529
|
}
|
|
@@ -470,6 +545,8 @@ function markClick(event) {
|
|
|
470
545
|
lastClickAt = Date.now()
|
|
471
546
|
clickBaseForeground = lastForeground
|
|
472
547
|
pendingForeground = null
|
|
548
|
+
// 手机上点画面:顺手把隐藏输入框聚焦,软键盘才会出现
|
|
549
|
+
if (event && event.pointerType && event.pointerType !== 'mouse') focusKeyboard()
|
|
473
550
|
}
|
|
474
551
|
|
|
475
552
|
canvasOfGuard()
|
|
@@ -566,6 +643,7 @@ window.addEventListener('pagehide', () => {
|
|
|
566
643
|
if (rfb !== null) { try { rfb.disconnect() } catch { /* 忽略 */ } }
|
|
567
644
|
})
|
|
568
645
|
|
|
646
|
+
setupMobileKeyboard()
|
|
569
647
|
setupToolbar()
|
|
570
648
|
|
|
571
649
|
function autoConnect() {
|
package/lib/vnc-boot.js
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 手机软键盘 → VNC 按键映射
|
|
3
|
+
*
|
|
4
|
+
* 背景:VNC 画面是 canvas,手机点它不会弹软键盘;noVNC 只抓物理键盘事件。
|
|
5
|
+
* 方案:页面放一个隐藏 textarea,手机键盘输入后把字符转换成 keysym 发出去。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** 特殊键 keysym(X11) */
|
|
9
|
+
export const SPECIAL_KEYS = Object.freeze({
|
|
10
|
+
Backspace: 0xff08,
|
|
11
|
+
Tab: 0xff09,
|
|
12
|
+
Enter: 0xff0d,
|
|
13
|
+
Escape: 0xff1b,
|
|
14
|
+
Delete: 0xffff,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
/** 普通符号 → 键位 code(US 键盘) */
|
|
18
|
+
const SYMBOL_CODES = {
|
|
19
|
+
' ': 'Space',
|
|
20
|
+
'-': 'Minus',
|
|
21
|
+
'=': 'Equal',
|
|
22
|
+
'[': 'BracketLeft',
|
|
23
|
+
']': 'BracketRight',
|
|
24
|
+
'\\': 'Backslash',
|
|
25
|
+
';': 'Semicolon',
|
|
26
|
+
"'": 'Quote',
|
|
27
|
+
'`': 'Backquote',
|
|
28
|
+
',': 'Comma',
|
|
29
|
+
'.': 'Period',
|
|
30
|
+
'/': 'Slash',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 需要按 Shift 的符号 → 对应的无 Shift 字符 */
|
|
34
|
+
const SHIFTED_SYMBOLS = {
|
|
35
|
+
'!': '1', '@': '2', '#': '3', '$': '4', '%': '5',
|
|
36
|
+
'^': '6', '&': '7', '*': '8', '(': '9', ')': '0',
|
|
37
|
+
'_': '-', '+': '=', '{': '[', '}': ']', '|': '\\',
|
|
38
|
+
':': ';', '"': "'", '<': ',', '>': '.', '?': '/', '~': '`',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function letterCode(letter) {
|
|
42
|
+
return 'Key' + letter.toUpperCase()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function digitCode(digit) {
|
|
46
|
+
return 'Digit' + digit
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 单个字符 → { keysym, code, shift }
|
|
51
|
+
* 支持:字母(大小写)、数字、常见符号、空格;不支持的返回 null。
|
|
52
|
+
*/
|
|
53
|
+
export function charToKey(char) {
|
|
54
|
+
if (typeof char !== 'string' || char.length === 0) return null
|
|
55
|
+
if (char === '\n' || char === '\r') return { keysym: SPECIAL_KEYS.Enter, code: 'Enter', shift: false }
|
|
56
|
+
if (char === '\b') return { keysym: SPECIAL_KEYS.Backspace, code: 'Backspace', shift: false }
|
|
57
|
+
if (char === ' ') return { keysym: 0x20, code: 'Space', shift: false }
|
|
58
|
+
if (char === '\t') return { keysym: SPECIAL_KEYS.Tab, code: 'Tab', shift: false }
|
|
59
|
+
|
|
60
|
+
if (SHIFTED_SYMBOLS[char]) {
|
|
61
|
+
const base = SHIFTED_SYMBOLS[char]
|
|
62
|
+
return { keysym: base.codePointAt(0), code: symbolCode(base), shift: true }
|
|
63
|
+
}
|
|
64
|
+
if (/^[a-z]$/u.test(char)) {
|
|
65
|
+
return { keysym: char.codePointAt(0), code: letterCode(char), shift: false }
|
|
66
|
+
}
|
|
67
|
+
if (/^[A-Z]$/u.test(char)) {
|
|
68
|
+
return { keysym: char.toLowerCase().codePointAt(0), code: letterCode(char), shift: true }
|
|
69
|
+
}
|
|
70
|
+
if (/^[0-9]$/u.test(char)) {
|
|
71
|
+
return { keysym: char.codePointAt(0), code: digitCode(char), shift: false }
|
|
72
|
+
}
|
|
73
|
+
if (SYMBOL_CODES[char]) {
|
|
74
|
+
return { keysym: char.codePointAt(0), code: SYMBOL_CODES[char], shift: false }
|
|
75
|
+
}
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function symbolCode(char) {
|
|
80
|
+
if (SYMBOL_CODES[char]) return SYMBOL_CODES[char]
|
|
81
|
+
if (/^[0-9]$/u.test(char)) return digitCode(char)
|
|
82
|
+
if (/^[a-z]$/u.test(char)) return letterCode(char)
|
|
83
|
+
return 'Unidentified'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** inputType → 特殊键 */
|
|
87
|
+
export function inputTypeToKey(inputType) {
|
|
88
|
+
if (inputType === 'deleteContentBackward') return { keysym: SPECIAL_KEYS.Backspace, code: 'Backspace', shift: false }
|
|
89
|
+
if (inputType === 'deleteContentForward') return { keysym: SPECIAL_KEYS.Delete, code: 'Delete', shift: false }
|
|
90
|
+
if (inputType === 'insertLineBreak' || inputType === 'insertParagraph') return { keysym: SPECIAL_KEYS.Enter, code: 'Enter', shift: false }
|
|
91
|
+
return null
|
|
92
|
+
}
|