title: How to update event.target.value on keypress?
body: <p>I am working to make postal code validation but I am not able to get <code>updatedValue</code> using <code>event.target.value</code> its showing <code>oldValue</code></p>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;input type="text"  style="color:black !important;width:100%;" (keypress)="numericOnly($event);" name="fname" [(ngModel)]='value' autofocus&gt;
  </code></pre>
  
  <p>.ts file </p>
  
  <pre><code> numericOnly(event): boolean {
          console.log("element", event);
          console.log('element.value', event.target.value);
          let patt = new RegExp("^[a-z A-Z 0-9]*-?[a-z A-Z 0-9]*$");
          console.log('this.value', this.value);
          let result = patt.test(event.target.value);
          console.log('result', result)
          if (result == false) {
              // event.target.value = this.value
              // this.value = event.target.value;
              const val = &lt;string&gt;event.target.value
              if (val &amp;&amp; val.length &gt; 0) {
                  this.value =  event.target.value;
                  event.preventDefault();
              }
  
          }
          return result;
      }
  </code></pre>
  
  <p>when I trying to access the target value using    <code>event.target.value</code> its giving oldVlaue
  i want to get recently typed value on <code>keypress</code> event.whenever I used <code>keyup</code> event its updating <code>ngModel</code> which I don't want. </p>
  
  <p><a href="https://i.stack.imgur.com/dUntS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dUntS.png" alt="enter image description here"></a></p>