title: how to select the dropdown value using key press angular 9
body: <p>The current scenario is in such a way that a drop down containing multiple options.</p>
  <pre><code> value: Values[] = [
      { value: '1', viewValue: '1' },
      { value: '2', viewValue: '2' },
      { value: '3', viewValue: '3' }
    ];`
  
  
  
  &lt;select formControlName=&quot;item&quot;&gt;
      &lt;option *ngFor=&quot;let i of foods&quot; [value]=&quot;i.value&quot;&gt;{{i.value}}&lt;/option&gt;
    &lt;/select&gt;
  </code></pre>
  <p>The requirement is that if I click 1 on the keyboard, then the option 1 needs to be selected. I've tried using @HostListener('window:keydown', ['$event']) but didn't worked. Are there any examples that can be used.? How to select the options using the keyboard inputs.??</p>
  <p>The sample code of the listener is below.</p>
  <pre><code> @HostListener('window:keydown', ['$event'])
   handleKeyboardEvent(event: KeyboardEvent) {
   this.keypressed = event.keyCode;
   console.log('this.keypressed', this.keypressed)
   }
  </code></pre>
  <p>It works when the drop-down is closed. If the drop-down is opened, then value of this.keypressed is not getting populated</p>