How can we generate and send a key event ("keypress", "keyup", "keydown") in Dart?
I tried:
// Context: import 'dart:html' as dom;
...
InputElement input = dom.querySelector(...);
var ev = new KeyEvent('keypress', keyCode: 65);
print("ev=$ev, and (ev is Event) is ${ev is Event}");
// ==> output: ev=Instance of 'KeyEvent', and (ev is Event) is true
input.dispatchEvent(ev);
// ==> yields
The last statement calls:
Caught Invalid class: expected instance of Event
Reports of exceptions that are evnot instances Event, and yet from the printed output we see what it is.
source
share