Search code examples
google-chrome-extensiongoogle-chrome-devtoolsgoogle-chrome-app

Using Chrome remote debugging for sending 'Enter' key


I am using Chrome remote debugging protocol in a Chrome extension is order to send keyboard events to a page. This is working well for standard input, but I am failing to find the right parameters to pass in order to create an 'Enter' key event. I am working on Windows. Here is the link to the protocol: https://developers.google.com/chrome-developer-tools/docs/protocol/1.1/input

I am aware that I can do it using plain JavaScript and KeyboardEvent (in a content-script) but this is not a valid solution for my needs. Anyone did it before and succeeded?

Thanks


Solution

  • OK, I figured it out... Here are the events that should be send:

    {
        "type" : "rawKeyDown",
        "windowsVirtualKeyCode" : 13,
        "unmodifiedText" : "\r",//This is the critical part
        "text" : "\r" //This is the critical part
    }
    

    Then the same event with type = "char" and "keyUp".

    Hope this will help someone.