My code includes a @HostListener
that is listening for document:keydown
events as shown below:
@HostListener('document:keydown', ['$event'])
selectHandler(event: KeyboardEvent) {
switch (event.key) {
case 'n':
this.useNode();
break;
case 'c':
this.useConnector();
break;
case 'd':
this.useDefault();
break;
case 'g':
this.useGrip();
break;
default:
break;
}
}
An issue arises when I try to use the Copy operation with Ctrl + C, as it triggers the case 'c'
in my code. How can I distinguish between pressing "Ctrl + C" alone and just "C"?