Keyboard button code doesn't work

Will someone please help me with my code? for some reason isn’t working.

    if (this.app.keyboard.wasPressed(pc.KEY_DOWN)){
        this.check("down");
    }      
    if (this.app.keyboard.wasPressed(pc.KEY_UP)) {
        this.check("up");
    }      
    if (this.app.keyboard.wasPressed(pc.KEY_LEFT)) {
        this.check("left");
    }      
    if (this.app.keyboard.wasPressed(pc.KEY_RIGHT)) {
        this.check("right");
    }      
};

Hello @Beckham_Olson! As far as I know this.check('test') does not exist in PlayCanvas. If you use console.log('test') instead, you will see your code is working correct.

It should work fine if it’s written inside update function. Also check() is not a defined function in playcanvas. You should use console.log(“down”); to debug.

There’s nothing obviously wrong with this code (without seeing the whole script). @Beckham_Olson, it’s generally advisable to post the link to a public scene that illustrates/reproduces the problem. That way, forum members can more quickly diagnose the problem.