How to dispatch a KeyEvent (to simulate typing) in Dart? -


How can we generate and transmit a major event ("keypress", "funnel" "Keydown") dart?

I have tried:

  // context: import 'dart: html' as dom; ... Input element input = dom.query selector (...); Var ev = new key event ('keypress', keycode: 65); Print ("ev = $ ev, and (ev is the event) $ {ev is event}"); // ==> Output: example of Ev = 'Kiwel', and (Event Event) is the true input. Disassociate event (eve); // ==> The result of the last statement is:  
  Invalid category caught: event # 0 expected event # 0 Node.dispatchEvent (... / Dart / dart / html /node.dart ** 86)  

Exception report is not an example of ev event And by the printed output so far we see that it is.

Obviously, this is identified as a bug:. Once it is fixed, I will post an update.

In the meantime I have found the only solution that repeated keypress events using TextEvent. Here is an accessory function that I have used

  / ** * This function is typing the value given in the input field *. There is a side effect to setting window focus for input. * / Zero Set InputWallueTextEvent (Input Input, String Value) {input..focus () .. Dispatches (new text event ('text input', data: value)); }  

Comments