mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-03 03:27:10 +00:00
fix(chrome): correct PressKey mappings to chromedp/kb constants
Old keyMap had "home":"\x00" (NUL byte) and arrow keys mapped to random punctuation runes (\x25-\x28 = % & ' () instead of arrow keys. "escape" was missing entirely while the V8 runtime emits it. Drop back/home (no browser navigation semantics) and route the remaining keys through chromedp/kb constants so they actually dispatch as the named keys.
This commit is contained in:
1 parent
1f525b6cdd
commit
65adfb9b2e
1 file changed
+11
-8
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/chromedp/cdproto/page"
|
||||
"github.com/chromedp/cdproto/runtime"
|
||||
"github.com/chromedp/chromedp"
|
||||
"github.com/chromedp/chromedp/kb"
|
||||
|
||||
"github.com/priyanshujain/sanderling/internal/driver"
|
||||
)
|
||||
@@ -191,15 +192,17 @@ func (d *Driver) PressKey(_ context.Context, key string) error {
|
||||
return chromedp.Run(d.tabCtx, chromedp.KeyEvent(k))
|
||||
}
|
||||
|
||||
// keyMap covers the keys web specs may emit (enter/tab/escape/arrows).
|
||||
// "back"/"home" are intentionally absent: backspace/NUL have no navigation
|
||||
// semantics in a browser, and the V8 action mix already excludes them.
|
||||
var keyMap = map[string]string{
|
||||
"back": "\b",
|
||||
"home": "\x00",
|
||||
"enter": "\r",
|
||||
"tab": "\t",
|
||||
"up": "\x26",
|
||||
"down": "\x28",
|
||||
"left": "\x25",
|
||||
"right": "\x27",
|
||||
"enter": kb.Enter,
|
||||
"tab": kb.Tab,
|
||||
"escape": kb.Escape,
|
||||
"up": kb.ArrowUp,
|
||||
"down": kb.ArrowDown,
|
||||
"left": kb.ArrowLeft,
|
||||
"right": kb.ArrowRight,
|
||||
}
|
||||
|
||||
func (d *Driver) Hierarchy(_ context.Context) (string, error) {
|
||||
|
||||
Reference in new issue
Block a user