title: How to submit a form by pressing Enter Key from any field in the form in Angular Material?
body: <p>I want to submit the form by pressing enter key without clicking on update button once any field is edited and update button gets enabled as below in the screenshot.</p>
  <p>This update form is a dialog which opens up on click of edit functionality on a row of the table.
  <a href="https://i.stack.imgur.com/ixYYV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ixYYV.jpg" alt="enter image description here" /></a></p>
  <p>Case:  Now form is edited on <strong>Emp Code</strong> field and it's highlighted, so on click of enter key this form should be submitted.</p>
  <p>Below is code sample of update form in HTML.</p>
  <pre><code>&lt;mat-card-content&gt;
      &lt;form class=&quot;example-form&quot; [formGroup]=&quot;docForm&quot;&gt;
        &lt;table&gt;
          &lt;tr&gt;
            .
            .
            &lt;td&gt;
              &lt;mat-form-field appearance=&quot;outline&quot;&gt;
                &lt;mat-label&gt;Emp Code&lt;/mat-label&gt;
                &lt;input matInput name=&quot;empCode&quot; formControlName=&quot;empCd&quot; maxLength = &quot;4&quot; &gt;
              &lt;/mat-form-field&gt;
            &lt;/td&gt;
           .
           .
         &lt;/tr&gt;
        &lt;/table&gt;
      &lt;/form&gt;
  &lt;/mat-card-content&gt;
  
  &lt;button mat-raised-button style=&quot;width: 95px;&quot; color=&quot;primary&quot; [disabled]='docForm.invalid || !docForm.dirty (click)=&quot;update()&quot;&gt; Update &lt;/button&gt;
  </code></pre>
  <p>I tried some approach, but not working as expected.</p>
  <pre><code> &lt;button mat-raised-button (keyup.enter)=&quot;!($event.target.tagName == 'TEXTAREA' || $event.target.tagName == 'BUTTON')&quot; 
    style=&quot;width: 95px;&quot; color=&quot;primary&quot; [disabled]='docForm.invalid || !docForm.dirty' (click)=&quot;update()&quot;&gt; Update &lt;/button&gt;
  </code></pre>
  <p>Thanks in advance for any help on this.</p>