You can achieve this yourself using SendDuiMessage.
Just pass the wanted parameters, like a key in this case, to this method as a JSON string.
On the DUI part you wan’t to have a handler which intercepts the event (just like in NUI) and execute the keypress.
Simple JS keypress example:
var keyboardEvent = document.createEvent('KeyboardEvent');
var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? 'initKeyboardEvent' : 'initKeyEvent';
keyboardEvent[initMethod](
'keydown', // event type: keydown, keyup, keypress
true, // bubbles
true, // cancelable
window, // view: should be window
false, // ctrlKey
false, // altKey
false, // shiftKey
false, // metaKey
40, // keyCode: unsigned long - the virtual key code, else 0
0, // charCode: unsigned long - the Unicode character associated with the depressed key, else 0
);
document.dispatchEvent(keyboardEvent);
Source: javascript - Is it possible to simulate key press events programmatically? - Stack Overflow
EDIT: may be a bit hacky to include custom js files inside webpages like youtube, etc. You may use a custom DUI site and embed your webpages there using iframes. (And some technolegies that bypass iframe-blocking websites).
P.S. I’ve done something similar some time ago.