MCPcopy Index your code
hub / github.com/Bistutu/FluentRead / setShortcut

Function setShortcut

userscripts.js:1470–1487  ·  view source on GitHub ↗
(shortcut)

Source from the content-addressed store, hash-verified

1468
1469// 快捷键处理
1470function setShortcut(shortcut) {
1471 // 1、移除旧的事件监听器
1472 if (shortcutManager.currentShortcut) {
1473 document.removeEventListener('keydown', shortcutListener);
1474 document.removeEventListener('keyup', shortcutListener);
1475 }
1476
1477 // 2、设置新的快捷键并添加事件监听器
1478 shortcutManager.currentShortcut = shortcut;
1479 document.addEventListener('keydown', shortcutListener);
1480 document.addEventListener('keyup', shortcutListener);
1481
1482 function shortcutListener(event) {
1483 if (event.key === shortcut) { // 按下相关快捷键,调整 ctrlPressed
1484 shortcutManager.hotkeyPressed = (event.type === 'keydown');
1485 }
1486 }
1487}
1488
1489// 判断是否为机器翻译
1490function isMachineTrans(model) {

Callers 2

setHotkeyFunction · 0.85
initApplicationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected