зеркало из https://github.com/mozilla/gecko-dev.git
33 строки
891 B
HTML
33 строки
891 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
</head>
|
|
<body>
|
|
<script>
|
|
window.addEventListener("Test:DispatchKeyEvents", aEvent => {
|
|
var keyCode = KeyEvent["DOM_" + aEvent.detail.code];
|
|
|
|
document.body.focus();
|
|
var evt = document.createEvent("KeyEvents");
|
|
evt.initKeyEvent("keydown", true, true, window,
|
|
false, false, false, false,
|
|
keyCode, 0);
|
|
document.body.dispatchEvent(evt);
|
|
|
|
evt = document.createEvent("KeyEvents");
|
|
evt.initKeyEvent("keypress", true, true, window,
|
|
false, false, false, false,
|
|
keyCode, 0);
|
|
document.body.dispatchEvent(evt);
|
|
|
|
evt = document.createEvent("KeyEvents");
|
|
evt.initKeyEvent("keyup", true, true, window,
|
|
false, false, false, false,
|
|
keyCode, 0);
|
|
document.body.dispatchEvent(evt);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|