Is there a way to choose multiple number elements in random order and save them to an array by holding down the control key (CTRL) and clicking on the element? For example, selecting 2 and 4 out of 5. I tried different methods but couldn't figure out how to combine the click event with @Hostlistener.
https://i.stack.imgur.com/kNWgi.png
<div class="nums">
<div *ngFor="let tempNum of [1, 2, 3, 4, 5]">
<span class="num" (click)="onNumClick(tempNum)">{{ tempNum }}</div>
</div>
</div>
@Hostlistener('window.keydown.control', ['$event'])
onKeyDown(event: KeyboardEvent) {
console.log('Control key clicked');
}
onNumClick(num: number) {
this.selectedNums.push(num);
}