Pregunta

I am looking at Dart API to find a way to listen to KeyUp event using capture mode. But with this new stream system there's no parameter to specify capture anymore:

document.body.onKeyUp.listen(callback); // where's the old "useCapture" parameter?
¿Fue útil?

Solución

To achieve the same thing with Streams, here's an example:

Element.keyUpEvent.forTarget(document.body, useCapture: true).listen((e) {
  // Do your stuff.
  print('Here we go');
});

The method we used above, creates a stream for you with capture mode. The Stream interface (listen() method) is quite generic, and thus can't have this specific functionality you are looking for.

Otros consejos

Alternative method:

GlobalEventHandlers.clickEvent.forTarget(dom.document, useCapture: true).listen((e) {
  // Do your stuff.
});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top