Animation not playing through script

I have an animation that does work and i’m trying to play it through a script. No error is given, but it doesn’t play.

var Playhitanim = pc.createScript('playhitanim');
Playhitanim.attributes.add('Animation', {
    type: 'asset'
});

// initialize code called once per entity
Playhitanim.prototype.initialize = function() {
    
};

// update code called every frame
Playhitanim.prototype.update = function(dt) {
    


 this.app.keyboard.on(pc.EVENT_KEYDOWN, this.keyDown, this); 
     this.entity.animation.play('untitled.json');
};
// swap method called for script hot-reloading
// inherit your script state here
// Playhitanim.prototype.swap = function(old) { };

// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/

Project: https://playcanvas.com/project/634746/overview/new-game-1

youre listening for an event every second in your update loop, put that keyboard listen code inside your initialize as it is an async function.

you are also missing your keydown function

var Playhitanim = pc.createScript('playhitanim');
Playhitanim.attributes.add('Animation', {
    type: 'asset'
});

// initialize code called once per entity
Playhitanim.prototype.initialize = function() {
     this.app.keyboard.on(pc.EVENT_KEYDOWN, this.keyDown, this); 
};

// any key down 
Playhitanim.prototype.keyDown= function(ev) {
  
     this.entity.animation.play('untitled.json');
};