How to listen to keyUp event in capture mode?

Issue

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?

Solution

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.

Answered By – Kai Sellgren

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *