The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(ego-browser): normalize named key casing
JackWanga62cd3745d14
diff --git a/package/ego-browser/scripts/real-browser-e2e/cases/page-keyboard.mjs b/package/ego-browser/scripts/real-browser-e2e/cases/page-keyboard.mjsindex c2bad00..d66ad30 100644--- a/package/ego-browser/scripts/real-browser-e2e/cases/page-keyboard.mjs+++ b/package/ego-browser/scripts/real-browser-e2e/cases/page-keyboard.mjs@@ -165,6 +165,28 @@ export function pageKeyboardInterfaceCase() {"uppercase modifier keeps the shortcut trusted",);+ await page.evaluate(() => {+ const input = document.querySelector("#text-area");+ input.value = "";+ input.focus();+ window.__pageKeyboardContractEvents = [];+ });+ await page.press("#text-area", "ENTER");+ await page.keyboard.press("escape");+ await page.keyboard.press("ARROWDOWN");+ const caseInsensitiveNamedKeys = (+ await page.evaluate("window.__pageKeyboardContractEvents")+ ).filter((event) => event.type === "keydown");+ assertEqual(+ caseInsensitiveNamedKeys.map((event) => event.code).join(","),+ "Enter,Escape,ArrowDown",+ "named keys accept case-insensitive spellings through both Page APIs"+ );+ assert(+ caseInsensitiveNamedKeys.every((event) => event.trusted === true),+ "case-insensitive named keys remain trusted input"+ );+await page.press("#text-area", "ControlOrMeta+A");await page.keyboard.type("replaced");await page.keyboard.press("ArrowLeft");diff --git a/package/ego-browser/src/driver/page-keyboard.ts b/package/ego-browser/src/driver/page-keyboard.tsindex 0d8f91e..d63271d 100644--- a/package/ego-browser/src/driver/page-keyboard.ts+++ b/package/ego-browser/src/driver/page-keyboard.ts@@ -287,9 +287,9 @@ function resolveSmartModifier(key: string,platform: string = process.platform,): string {- // Modifier names are forgiving because agents often use protocol-style- // uppercase constants. Ordinary key names remain case-sensitive.- const normalized = MODIFIER_ALIASES.get(key.toLowerCase()) ?? key;+ const lower = key.toLowerCase();+ const normalized =+ MODIFIER_ALIASES.get(lower) ?? NAMED_KEY_NAMES.get(lower) ?? key;if (normalized === "ControlOrMeta") {return platform === "darwin" ? "Meta" : "Control";}@@ -528,6 +528,11 @@ function buildKeyboardLayout(): Map<string, KeyDefinition> {}const keyboardLayout = buildKeyboardLayout();+const NAMED_KEY_NAMES = new Map(+ [...keyboardLayout.keys()]+ .filter((key) => key.length > 1)+ .map((key) => [key.toLowerCase(), key]),+);function editingCommands(code: string,diff --git a/package/ego-browser/src/page-model.test.mjs b/package/ego-browser/src/page-model.test.mjsindex 7543068..40072da 100644--- a/package/ego-browser/src/page-model.test.mjs+++ b/package/ego-browser/src/page-model.test.mjs@@ -3700,6 +3700,57 @@ test("Page keyboard accepts case-insensitive modifier names", async () => {});});+test("Page keyboard accepts case-insensitive named key names", async () => {+ await withFixture(async (fixture) => {+ const task = taskForRound(fixture, "round-a");+ const page = await openTestPage(task, "https://example.test/first");++ await page.keyboard.press("ENTER");+ await page.keyboard.press("escape");+ await page.press("[contenteditable]", "ARROWDOWN");++ const keyDowns = fixture.calls+ .filter(+ ([kind, method, params]) =>+ kind === "cdp" &&+ method === "Input.dispatchKeyEvent" &&+ (params.type === "keyDown" || params.type === "rawKeyDown"),+ )+ .map(([, , params]) => params);+ assert.deepEqual(+ keyDowns.map(({ code }) => code),+ ["Enter", "Escape", "ArrowDown"],+ );+ });+});++test("Page keyboard keeps single-character key case significant", async () => {+ await withFixture(async (fixture) => {+ const task = taskForRound(fixture, "round-a");+ const page = await openTestPage(task, "https://example.test/first");++ await page.keyboard.press("a");+ await page.keyboard.press("A");++ const keyDowns = fixture.calls+ .filter(+ ([kind, method, params]) =>+ kind === "cdp" &&+ method === "Input.dispatchKeyEvent" &&+ params.type === "keyDown" &&+ params.code === "KeyA",+ )+ .map(([, , params]) => params);+ assert.deepEqual(+ keyDowns.map(({ key, text }) => ({ key, text })),+ [+ { key: "a", text: "a" },+ { key: "A", text: "A" },+ ],+ );+ });+});+test("Page keyboard maps portable editing shortcuts on Windows", async () => {await withFixture(async (fixture) => {const task = taskForRound(fixture, "round-a", { platform: "win32" });diff --git a/package/ego-browser/src/public-api-schema.test.mjs b/package/ego-browser/src/public-api-schema.test.mjsindex 0c3d18e..2e710cf 100644--- a/package/ego-browser/src/public-api-schema.test.mjs+++ b/package/ego-browser/src/public-api-schema.test.mjs@@ -169,6 +169,10 @@ test("the generated reference contains signatures and option descriptions", () =markdown,/`await page\.waitForFunction\(fnOrString, argument\?, \{ timeout\?, polling\? \}\)`/,);+ assert.match(+ markdown,+ /`await page\.keyboard\.press\(chord, \{ delay\? \}\)`.*Named keys are case-insensitive.*single-character keys preserve case/,+ );assert.match(markdown,/const downloadPromise = page\.waitForEvent\("download"\); await page\.click\(selector\)/,diff --git a/package/ego-browser/src/public-api-schema.ts b/package/ego-browser/src/public-api-schema.tsindex 3cd0d1c..71d51ae 100644--- a/package/ego-browser/src/public-api-schema.ts+++ b/package/ego-browser/src/public-api-schema.ts@@ -525,7 +525,8 @@ export const PUBLIC_API_SCHEMA: readonly PublicApiEntry[] = [{name: "Page.press",signature: "await page.press(selector, chord, { delay?, timeout? })",- summary: "Focus one element and press a key or shortcut chord.",+ summary:+ "Focus one element and press a key or shortcut chord. Named keys are case-insensitive; single-character keys preserve case.",options: { delay, timeout: actionTimeout },},{@@ -621,7 +622,8 @@ export const PUBLIC_API_SCHEMA: readonly PublicApiEntry[] = [{name: "Page.keyboard.press",signature: "await page.keyboard.press(chord, { delay? })",- summary: "Press and release a key or portable shortcut chord.",+ summary:+ "Press and release a key or portable shortcut chord. Named keys are case-insensitive; single-character keys preserve case.",options: { delay },},{diff --git a/skills/ego-browser/references/api.md b/skills/ego-browser/references/api.mdindex d9c5f01..c55f114 100644--- a/skills/ego-browser/references/api.md+++ b/skills/ego-browser/references/api.md@@ -75,7 +75,7 @@ Selectors accept refs, Ego locators, XPath, and raw CSS. A small compatibility s| `await page.fill(selector, value, { clearFirst?, timeout? })` | `clearFirst` — Clear the current value before filling.<br>`timeout` — Maximum wait for the element to become usable in milliseconds; defaults to 3000. | Fill the selected field, its editing host, or its unique fillable descendant, then confirm editing took effect. || `await page.selectOption(selector, valueOrValues, { timeout? })` | `timeout` — Maximum wait for the element to become usable in milliseconds; defaults to 3000. | Select by a value-or-label string or { value?, label?, index? }; arrays select multiple options, while null or [] clears the selection. The select must be enabled, but disabled options remain programmatically selectable. || `await page.focus(selector, { timeout? })` | `timeout` — Maximum wait for the element to become usable in milliseconds; defaults to 3000. | Focus the element, its nearest interactive ancestor, or its unique editable descendant. |-| `await page.press(selector, chord, { delay?, timeout? })` | `delay` — Input delay in milliseconds.<br>`timeout` — Maximum wait for the element to become usable in milliseconds; defaults to 3000. | Focus one element and press a key or shortcut chord. |+| `await page.press(selector, chord, { delay?, timeout? })` | `delay` — Input delay in milliseconds.<br>`timeout` — Maximum wait for the element to become usable in milliseconds; defaults to 3000. | Focus one element and press a key or shortcut chord. Named keys are case-insensitive; single-character keys preserve case. || `await page.setInputFiles(selector, pathOrPaths)` | — | Set files on a file input resolved from the input, its label, or a unique descendant. || `page.waitForFileChooser({ timeout? })` | `timeout` — Maximum duration in milliseconds. | Wait for a dynamically created file chooser. || `await page.close()` | — | Close this Page after confirming its tab disappeared. |@@ -105,11 +105,11 @@ Selectors accept refs, Ego locators, XPath, and raw CSS. A small compatibility s## Page.keyboard-| API | Options | Purpose |-| ---------------------------------------------- | -------------------------------------- | ------------------------------------------------------------------------------- |-| `await page.keyboard.down(key)` | — | Press and hold a keyboard key. |-| `await page.keyboard.up(key)` | — | Release a keyboard key. |-| `await page.keyboard.press(chord, { delay? })` | `delay` — Input delay in milliseconds. | Press and release a key or portable shortcut chord. |-| `await page.keyboard.type(text, { delay? })` | `delay` — Input delay in milliseconds. | Type text using physical keys where possible. |-| `await page.keyboard.insertText(text)` | — | Insert text without synthesizing key presses. |-| `await page.keyboard.paste(textOrContent)` | — | Send native paste with a string or { text, html? }, then restore the clipboard. |+| API | Options | Purpose |+| ---------------------------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |+| `await page.keyboard.down(key)` | — | Press and hold a keyboard key. |+| `await page.keyboard.up(key)` | — | Release a keyboard key. |+| `await page.keyboard.press(chord, { delay? })` | `delay` — Input delay in milliseconds. | Press and release a key or portable shortcut chord. Named keys are case-insensitive; single-character keys preserve case. |+| `await page.keyboard.type(text, { delay? })` | `delay` — Input delay in milliseconds. | Type text using physical keys where possible. |+| `await page.keyboard.insertText(text)` | — | Insert text without synthesizing key presses. |+| `await page.keyboard.paste(textOrContent)` | — | Send native paste with a string or { text, html? }, then restore the clipboard. |