-2

I've been looking around, and I can't find an answer to this. I would like to have a mat dialog box open when a customer just starts typing. No focus nor input. Just starts typing. I'm sure the answer is simple, but I just can't find it. Thanks in advance!

Ken White
  • 120,522
  • 13
  • 212
  • 426
Kevin Wilde
  • 71
  • 1
  • 8

2 Answers2

2

A simple host listener should do the trick:

@HostListener('window:keyup', ['$event'])
  keyEvent(event: KeyboardEvent) {
      this.openDialog();
  }

Where openDialog is the function that triggers your MatDialog.

bamoure
  • 51
  • 1
1

You can use in your input this:

<input (change)="doSomething($event.target.value)">

Using (change) event you can do something when start typing.

Let me know it worked for you.

Jose Vicente
  • 108
  • 7