claude-opencode-viewer 2.1.5 → 2.1.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.
Files changed (2) hide show
  1. package/index.html +31 -4
  2. package/package.json +1 -1
package/index.html CHANGED
@@ -500,10 +500,37 @@
500
500
  'tab': '\t'
501
501
  };
502
502
 
503
+ // 方向键列表
504
+ var ARROW_KEYS = ['up', 'down', 'left', 'right'];
505
+
503
506
  function sendKey(keyName) {
504
- // 点击虚拟按键时收起手机键盘
505
- if (inputField && isMobile) {
506
- inputField.blur();
507
+ var isArrowKey = ARROW_KEYS.indexOf(keyName) !== -1;
508
+
509
+ // 方向键特殊处理:根据焦点位置决定行为
510
+ if (isArrowKey) {
511
+ if (inputFocused && inputField) {
512
+ // 焦点在输入框:模拟方向键操作输入框光标
513
+ var cursorPos = inputField.selectionStart;
514
+ var textLen = inputField.value.length;
515
+
516
+ if (keyName === 'left' && cursorPos > 0) {
517
+ inputField.setSelectionRange(cursorPos - 1, cursorPos - 1);
518
+ } else if (keyName === 'right' && cursorPos < textLen) {
519
+ inputField.setSelectionRange(cursorPos + 1, cursorPos + 1);
520
+ }
521
+ // 上下方向键在单行输入框中无操作
522
+ return;
523
+ } else {
524
+ // 焦点在终端:发送方向键到终端,并收起键盘
525
+ if (inputField && isMobile) {
526
+ inputField.blur();
527
+ }
528
+ }
529
+ } else {
530
+ // 非方向键:点击时收起键盘
531
+ if (inputField && isMobile) {
532
+ inputField.blur();
533
+ }
507
534
  }
508
535
 
509
536
  // Enter 键特殊处理:根据焦点位置决定行为
@@ -527,7 +554,7 @@
527
554
  return;
528
555
  }
529
556
 
530
- // 其他按键直接发送
557
+ // 其他按键直接发送到终端
531
558
  var key = KEY_MAP[keyName];
532
559
  if (key && ws && ws.readyState === 1 && !isTransitioning) {
533
560
  console.log('[sendKey] sending:', keyName, '->', key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-opencode-viewer",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "A unified terminal viewer for Claude Code and OpenCode with seamless switching",
5
5
  "type": "module",
6
6
  "main": "server.js",