I was searching for a way to bind to multiple key events - specifically, Shift+Enter - but couldn't find any good resources online. But after logging the keydown binding
<textarea (keydown)=onKeydownEvent($event)></textarea>
I discovered that the keyboard event provided all of the information I needed to detect Shift+Enter. Turns out that $event
returns a fairly detailed KeyboardEvent.
onKeydownEvent(event: KeyboardEvent): void {
if (event.keyCode === 13 && event.shiftKey) {
// On 'Shift+Enter' do this...
}
}
There also flags for the CtrlKey, AltKey, and MetaKey (i.e. Command key on Mac).
No need for the KeyEventsPlugin, JQuery, or a pure JS binding.