Using Chrome DevTools Protocol Input.dispatchKeyEvent or Input.dispatchMouseEvent to send an event

I'm writing a DSL that will interact with a page via Google Chrome's Remote Debugging API.

The INPUT domain (link here: https://chromedevtools.github.io/devtools-protocol/1-2/Input/) lists two functions that can be used for sending events: Input.dispatchKeyEvent and Input.dispatchMouseEvent.

I can't seem to figure out how to specify the target element as there is no link between the two functions and DOM.NodeId, or an intermediate API that accepts a DOM.NodeId which then returns an X,Y co-ordinate.

I know that it's possible to use Selenium, but I'm interested in doing directly using WebSockets.

Any help is appreciated.