如何在捕获模式下监听keyUp事件?

问题描述:

我正在查看Dart API以找到使用捕获模式来侦听KeyUp事件的方法。但有了这个新的流系统有没有参数指定捕获了:如何在捕获模式下监听keyUp事件?

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

为了实现与流同样的事情,在这里有一个例子:

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

我们上面所使用的方法,创建流你用捕捉模式。 Stream接口(listen()方法)非常通用,因此不能具有您正在寻找的这种特定功能。

替代方法:

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