Ero alla ricerca di un modo per associare a più eventi chiave, in particolare Maiusc + Invio, ma non sono riuscito a trovare alcuna buona risorsa online. Ma dopo l'accesso il legame
<textarea (keydown)=onKeydownEvent($event)></textarea>
keydown ho scoperto che l'evento della tastiera fornito tutte le informazioni di cui avevo bisogno per rilevare Maiusc + Invio. Risulta che $event
restituisce un abbastanza dettagliato KeyboardEvent.
onKeydownEvent(event: KeyboardEvent): void {
if (event.keyCode === 13 && event.shiftKey) {
// On 'Shift+Enter' do this...
}
}
C'è anche bandiere per il ctrlKey, altKey, e metakey (tasto cioè Command su Mac).
Nessuna necessità per KeyEventsPlugin, JQuery o un binding JS puro.
Forse questo potrebbe darvi un suggerimento https://github.com/angular/angular/issues/523, è piuttosto vecchio però. –