aboutsummaryrefslogtreecommitdiff
path: root/src/domains/keyboard.ts
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-28 20:30:49 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commitb67faca60b21b0cf74d5c967f0f8d215ad601e93 (patch)
tree12e8580e1b88c3ce6a2d9157cfa678cb7a55a73c /src/domains/keyboard.ts
parenta6ec1d0915106b127affbd6b5fcc9efec48ef712 (diff)
refactor(domains): strip comment noise
Removes module banners, step markers, and comments restating the code. Keeps one-line notes for safeJs's trust boundary, the select-match null sentinels, the TUI width clamp, the single-window tab rule, the input synthesis quirks (char events, keyCode, mousemove, focus, compositor), the stale AX value, ignored-wrapper recursion, and isolated-tab routing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/domains/keyboard.ts')
-rw-r--r--src/domains/keyboard.ts10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/domains/keyboard.ts b/src/domains/keyboard.ts
index 4ee8243..f0f1a6d 100644
--- a/src/domains/keyboard.ts
+++ b/src/domains/keyboard.ts
@@ -97,9 +97,7 @@ export const pressKeyTool = defineBrowserTool({
};
const down = await cdpCall(client, "Input.dispatchKeyEvent", downParams);
if (!down.success) return down;
- // For a printable character with no command modifier (Ctrl/Meta/Alt = 1|2|4),
- // emit a `char` event so the page receives keypress/textInput and the
- // character is actually inserted. Shift (8) is allowed (capitals/symbols).
+ // A printable character needs a `char` event for the page to receive keypress/textInput and actually insert it; Shift (8) still counts as printable.
const hasCommandModifier = (modifiers & (1 | 2 | 4)) !== 0;
if (isChar && !hasCommandModifier) {
const charEv = await cdpCall(client, "Input.dispatchKeyEvent", { type: "char", text: k, key: k });
@@ -143,12 +141,8 @@ export const dispatchKeyTool = defineBrowserTool({
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
const eventType = args.eventType ?? "keydown";
const target = args.ref ?? args.selector ?? "";
- // Legacy handlers commonly branch on e.keyCode/e.which (e.g. === 13 for
- // Enter) rather than e.key, so populate both. virtualKeyCode maps named
- // keys and single chars; 0 for anything unknown.
+ // Legacy handlers branch on e.keyCode/e.which rather than e.key, so populate both.
const code = virtualKeyCode(args.key);
- // Ref path: dispatch on the single resolved node. Selector path: dispatch on
- // all matches (preserves the original multi-match behavior).
if (args.ref !== undefined) {
const objectId = await resolveRefToObjectId(client, args.ref);
if (!objectId.success) return objectId;