title: ionic 3 Keyboard events, keycode always 0
body: <p>I am trying to control what a user can type to a specific input in my ionic 3 app.
  For example i have an <code>input type='text'</code> that i am allowing only numbers and underscores to it, and i am trying to achieve this using keyboard event.</p>
  <p>This works on browsers but not on actual android, since all keyCode are 0;</p>
  <p>Please advice how to deal with such thing, and am i using the best approach?</p>
  <p>Html code:</p>
  <pre><code>&lt;form [formGroup]=&quot;pinForm&quot;&gt;
    &lt;div class=&quot;modal-input&quot;&gt;
      &lt;ion-item&gt;
        &lt;ion-input type=&quot;text&quot; [(ngModel)]=&quot;pin&quot; #pinNumber&gt;&lt;/ion-input&gt;
      &lt;/ion-item&gt;
    &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>ts Code:</p>
  <pre><code>@ViewChild('pinNumber') inputPin:any;
  @HostListener(&quot;keydown&quot;, [&quot;$event&quot;])
    onKeyDown(e: KeyboardEvent) {
       //here i am controlling the input to do what ever i need
       console.log(e);
    }
  </code></pre>
  <p>the code above works in browser on pc but not on actual device
  as shown below its all 0's</p>
  <p>so how to know what key is pressed?</p>
  <blockquote>
  <p>altGraphKey: false</p>
  <p>altKey: false</p>
  <p>bubbles: true</p>
  <p>cancelBubble: false</p>
  <p>cancelable: true</p>
  <p>charCode: 0</p>
  <p>clipboardData: undefined</p>
  <p>ctrlKey: false</p>
  <p>currentTarget: null</p>
  <p>defaultPrevented: true</p>
  <p>detail: 0</p>
  <p>eventPhase: 0</p>
  <p>keyCode: 0</p>
  <p>keyIdentifier: &quot;U+0000&quot;</p>
  <p>keyLocation: 0</p>
  <p>layerX: 0</p>
  <p>layerY: 0</p>
  <p>location: 0</p>
  <p>metaKey: false</p>
  <p>pageX: 0</p>
  <p>pageY: 0</p>
  <p>returnValue: false</p>
  <p>shiftKey: false</p>
  <p>srcElement: input.text-input text-input-md</p>
  <p>target: input.text-input text-input-md</p>
  <p>timeStamp: 1516972480017</p>
  <p>type:&quot;keydown&quot;</p>
  <p>view: Window</p>
  <p>which: 0</p>
  <p><strong>proto</strong>: KeyboardEvent</p>
  </blockquote>