title: windows phone 8.1 textbox character virtualKey validation
body: <p>im develeoping windows phone 8.1 app.
  In a textbox I want to prevent the user from inputting any non-digital letter only [0-9].</p>
  
  <p>So here is my code:</p>
  
  <pre><code> private void NumKeyDown(object sender, KeyRoutedEventArgs e)
          {
  
             bool isNumber = (e.Key == Windows.System.VirtualKey.Number0 ||
                   e.Key == VirtualKey.Number1 ||
                   e.Key == VirtualKey.Number2 ||
                   e.Key == VirtualKey.Number3 ||
                   e.Key == VirtualKey.Number4 ||
                   e.Key == VirtualKey.Number5 ||
                   e.Key == VirtualKey.Number6 ||
                   e.Key == VirtualKey.Number7 ||
                   e.Key == VirtualKey.Number8 ||
                   e.Key == VirtualKey.Number9 ||
                   e.Key == VirtualKey.Back);
  
              CoreVirtualKeyStates shiftState = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift);
  
  
              bool shiftIsNotDown = true;
              if ((shiftState &amp; CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down)
                  shiftIsNotDown = false;
  
              e.Handled = !(isNumber &amp;&amp; shiftIsNotDown);
  
          }
  </code></pre>
  
  <p>it works but there are two major flaws :</p>
  
  <p>1- it also accept the shifted-characters( i.e !@#$%^&amp;*) while that is not wanted.</p>
  
  <p>2- when I start the app the textbox is filled with a number. I can input any number or characters(!@#$%^), also I can delete using the <code>BACKSPACE</code>. during this time the <code>ShiftState</code> is <code>NONE</code>. However once I delete all content in the textbox using the <code>BACKSPACE</code> the <code>ShiftState</code> changes to [ <code>locked | Down</code> ] and I become unable to input anything in that text box.</p>
  
  <p>notice that i never touch the shift button !</p>
  
  <p>where am I wrong here??</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I discovered that using the swipe feature will input texts letters without triggering the keyDown event I was applying :(</p>
  
  <p>any help is appreciated</p>