该Mousetrap.js库可以让您绑定的回调函数,像这样的键:
Mousetrap.bind('space', function, 'keydown');
在不使用末日巴士的情况下将流附加到此的最佳方法是什么?我应该使用emitter或pool?
我正试图在这个小提琴中连接箭头键:jsfiddle.net/vzafq25w
您可以使用通用包装器 stream
var leftKeys = Kefir.stream(function(emitter){
Mousetrap.bind('left', function(e) {
emitter.emit(e);
console.log(e);
});
return function(){
// unbind
};
});
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/be9200kh/1/
| 归档时间: |
|
| 查看次数: |
1115 次 |
| 最近记录: |