app.keyboard.isPressed throws error

although it appears in so many projects, when i added

    if (app.keyboard.isPressed(pc.KEY_LEFT))
    {

    }

to Update, i get an error thrown

that’s the project, the script is ‘ChangeTexture’.

app is undefined in the function scope that you are using it in. Either create a local variable named app and assigning it this.app or use this.app instead

1 Like

gatcha, once again
thanks alot.
now it works but it happens every frame WHILE key is pressed.
is there a command for key down & key up?

https://developer.playcanvas.com/en/api/pc.KeyboardEvent.html