I dont know if right place to ask for observable help but I try!

I dont know if right place to ask for observable help but I try!
0
#1
>  let Plane_SPEED=22;
>     let plane$ = game$.pipe(
>     withLatestFrom(input$,input2$)
>     
>     ,scan(([ss,s,w],[ticl,toc,tic]) => {
>       let Plane_WIDTH=100;
>       let speed=2
>       if(s==undefined){s=0}
>       
>       let next=this.paddlepos+toc*33*ticl.deltaTime
>       
>       return Math.max(Math.min(next, this.myCanvas.nativeElement.width - Plane_WIDTH / 2), Plane_WIDTH / 2);
>       }),
>      // sample(input$),
>       distinctUntilChanged())
>   
>   plane$.subscribe(data=>this.update(data)) 
> 
> const input$ = 
>     merge(
>         fromEvent(document, 'keydown', event => {
>           let x=this.paddlepos;
>             switch (event.keyCode) {
>                 case PADDLE_KEYS.left:
>                     return this.paddlepos=-1
>                 case PADDLE_KEYS.right:
>                    return this.paddlepos=+1
>                 default:
>                     return null;
>             }
> 
>    ))
>  const game$ =interval(22, animationFrameScheduler ).pipe(
>         map(() => ({
>             time: Date.now(),
>             deltaTime: null,
>             //pox:this.myCanvas.nativeElement.width / 2
>         }))
>         ,scan(
>             (previous, current) => ({
>                 time: current.time,
>                 deltaTime: (current.time - previous.time) / 1000,
>               //  pox: (current.pox+previous.pox)
>         
>             })
>         ))

Okay so this is the code I know it is maybe needed to do a codepen but my question is about this code,
right now the expected behaviour is to have a box animated every frame in browser and when i press arrow left and right it is suppose to move while i hold the key only… but actual behaviour is i press right arrow and i get a smooth movement to the right stopping outside half the canvas if i press left it fixes itself in the start position… and code in pure js is just observable. dot notation to acess the operators in typescript u need to use pipe, etx if Anyone good at math know this stuff Id be happy =)

#2

You’re going to need a keyup event to update your observable to tell it that the condition has changed.

#3

okay but I have been doing this a week
'keyup' event=> 0
didnt help it didnt move at all instead, I dont know what I doing wrong I trial and error this for a week
to get the hang of reactive streams and something must be wrong in the formula?
anyway I hope someone can help out I sort of wanted to make it on my own but I will keep trying

#4

The reason that you’re seeing the animation when you hit a key but don’t see any change when you stop pressing is because your code is only listening to the key going down. It’s not paying attention to the end of the press.