(shortcut)
| 1468 | |
| 1469 | // 快捷键处理 |
| 1470 | function 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 | // 判断是否为机器翻译 |
| 1490 | function isMachineTrans(model) { |
no outgoing calls
no test coverage detected