ui-event-simulator
Version:
Simulate browser UI-Events
35 lines (29 loc) • 1 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<title>UIEvent Simulator</title>
<script type="importmap">
{
"imports": {
"ui-event-simulator": "/ui-event-simulator.js"
}
}
</script>
</head>
<body>
<div id="test" style="width: 400px; height: 400px; background: red;" tabindex="1"></div>
<script type="module">
import UIEventSimulator from 'ui-event-simulator';
document.body.addEventListener('click',(e)=>alert(e.type+" Body"));
var test = document.getElementById('test');
test.addEventListener('dblclick',(e)=>alert(e.type));
test.addEventListener('keydown',(e)=>alert(e.type + " - " + e.key));
test.addEventListener('mousedown',(e)=>alert(e.type));
UIEventSimulator.fire('click', document.body);
UIEventSimulator.fire('dblclick', test);
UIEventSimulator.fireAt('keydown', 100, 100, {key: 'A'});
UIEventSimulator.fire('mousedown', test);
</script>
</body>
</html>