Ahmed
Ahmed

Reputation: 1789

How to listen to keyUp event in capture mode?

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?

Upvotes: 2

Views: 226

Answers (2)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 658037

Alternative method:

GlobalEventHandlers.clickEvent.forTarget(dom.document, useCapture: true).listen((e) {
  // Do your stuff.
});

Upvotes: 2

Kai Sellgren
Kai Sellgren

Reputation: 30312

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.

Upvotes: 6

Related Questions