So I'm using window to watch for keypresses so I can change the direction a dot is going on a canvas
ngOnInit() {
this.ctx = this.canvas.nativeElement.getContext('2d');
this.ctx.fillStyle = 'red';
this.square = new Square(this.ctx)
this.square.draw()
window.addEventListener('keydown', function (event) {
this.directionChange(event);
});
}
How would I go to pass that event into directionChange() which is located inside of the components ts
This is all my html
<canvas #canvas width="600" height="300"></canvas>
<button (click)="play()">Play</button>