Open tuwibu opened 10 months ago
What's the problem? Have you checked #1357?
Proof error:
This is example:
page1, _ := chromedp.NewContext(browserCtx)
if err := chromedp.Run(page1,
chromedp.Navigate("https://www.youtube.com/"),
); err != nil {
logger.Error(err.Error())
}
time.Sleep(1 * time.Second)
if err := chromedp.Run(page1,
chromedp.SendKeys("input#search", "anime", chromedp.NodeVisible),
); err != nil {
logger.Error(err.Error())
}
time.Sleep(1 * time.Second)
if err := chromedp.Run(page1,
chromedp.KeyEvent("a", chromedp.KeyModifiers(input.ModifierCtrl)),
); err != nil {
logger.Error(err.Error())
}
It works on my system (linux/amd64) correctly. I don't have Windows 11 to test the issue. Does it work if you start the browser and press Ctrl+a manually?
Yep, in chrome manually i can press Ctrl
+a
I had used your demo, its still error
Thank you! I have managed to reproduce the issue on Windows (both Win 10 and Win 11).
chromedp
sends these commands:
-> {"id":53,"sessionId":"28531763C0BD8289A494E20D666B8D77","method":"Input.dispatchKeyEvent","params":{"type":"keyDown","modifiers":2,"code":"KeyA","key":"a","windowsVirtualKeyCode":65,"nativeVirtualKeyCode":65,"autoRepeat":false,"isKeypad":false,"isSystemKey":false}}
-> {"id":54,"sessionId":"28531763C0BD8289A494E20D666B8D77","method":"Input.dispatchKeyEvent","params":{"type":"char","modifiers":2,"text":"a","unmodifiedText":"a","code":"KeyA","key":"a","windowsVirtualKeyCode":97,"nativeVirtualKeyCode":97,"autoRepeat":false,"isKeypad":false,"isSystemKey":false}}
-> {"id":55,"sessionId":"28531763C0BD8289A494E20D666B8D77","method":"Input.dispatchKeyEvent","params":{"type":"keyUp","modifiers":2,"code":"KeyA","key":"a","windowsVirtualKeyCode":65,"nativeVirtualKeyCode":65,"autoRepeat":false,"isKeypad":false,"isSystemKey":false}}
And I have tested Puppeteer with this code:
await page.keyboard.down('Control');
await page.keyboard.press('a');
await page.keyboard.up('Control');
Puppeteer does not have this issue. It sends these commands:
SEND ► ['{"method":"Input.dispatchKeyEvent","params":{"type":"rawKeyDown","modifiers":2,"windowsVirtualKeyCode":17,"code":"ControlLeft","key":"Control","text":"","unmodifiedText":"","autoRepeat":false,"location":1,"isKeypad":false,"commands":[]},"id":27,"sessionId":"DF8CA216724291A14D662105A5CAFFF2"}']
SEND ► ['{"method":"Input.dispatchKeyEvent","params":{"type":"rawKeyDown","modifiers":2,"windowsVirtualKeyCode":65,"code":"KeyA","key":"a","text":"","unmodifiedText":"","autoRepeat":false,"location":0,"isKeypad":false},"id":28,"sessionId":"DF8CA216724291A14D662105A5CAFFF2"}']
SEND ► ['{"method":"Input.dispatchKeyEvent","params":{"type":"keyUp","modifiers":2,"key":"a","windowsVirtualKeyCode":65,"code":"KeyA","location":0},"id":29,"sessionId":"DF8CA216724291A14D662105A5CAFFF2"}']
SEND ► ['{"method":"Input.dispatchKeyEvent","params":{"type":"keyUp","modifiers":0,"key":"Control","windowsVirtualKeyCode":17,"code":"ControlLeft","location":1},"id":30,"sessionId":"DF8CA216724291A14D662105A5CAFFF2"}']
It's the following command that causes the trouble:
-> {"id":54,"sessionId":"28531763C0BD8289A494E20D666B8D77","method":"Input.dispatchKeyEvent","params":{"type":"char","modifiers":2,"text":"a","unmodifiedText":"a","code":"KeyA","key":"a","windowsVirtualKeyCode":97,"nativeVirtualKeyCode":97,"autoRepeat":false,"isKeypad":false,"isSystemKey":false}}
Maybe chromedp
should not dispatch this char
event when any of the modifiers besides shift
is pressed.
@kenshaw Any suggestions?
What versions are you running?
What did you do? Include clear steps.
What did you expect to see?
What did you see instead?