I have a piece of code in javascript that sends a request to the server with a list of my keypresses. The way I get the keycodes is like this:
window.onkeypress = function (event) {
keypresses.push(event.which);
}
On my golang code, I'm trying to use these as to type some text in the chromedp instance using:
chromedp.Run(ctx, chromedp.KeyEvent(key))
The problem is that this types literally the key code, I've been trying to find out a way to do this but I have no idea.
Does anyone know how to do this?
Thanks in advance.
Edit
I have added the code to github, here's the repo: https://github.com/ericmackrodt/netscape-proxy
The client collects the keycodes and sends them as a query param here:
https://github.com/ericmackrodt/netscape-proxy/blob/main/templates/browser.html#L48
The server receives the keycodes from the client here:
https://github.com/ericmackrodt/netscape-proxy/blob/main/server.go#L80
And then parses it and tries to type them here:
https://github.com/ericmackrodt/netscape-proxy/blob/main/browser/browser.go#L70
The code should be fairly easy to reproduce.