Is there a way to listen for ctrl + left mouse click event.
I’m able to capture the ctrl click but how do i combine it with the left mouse click.
@HostListener('document:keyup', ['$event'])
handleKeyboardEvent(event: KeyboardEvent) {
console.log(event.key)
if (event.key == 'Control'){
console.log(true)
}
}
this is what I have for the ctrl click.
Thank you.
2
Answers
event.key == 'Control'
checks is control pressed as separate event. You need event.ctrlKey whick is boolean and represents whether control been pressed during the event (in your case click) or not. So just listen click event, and when it is triggered checkif(event.ctrlKey)
You can check if the CTRL Key is pressed or not from event.ctrlKey