title: How to figure out which key was pressed on a BlackBerry
body: <p><strong>What I want</strong>: To know when the user has pressed the button that has the number '2' on it, for example. I don't care whether "Alt" or "Shift" has been pressed. The user has pressed a button, and I want to evaluate whether this button has '2' printed on it.</p>
  
  <p>Naturally, if I switch devices this key will change. On a Bold 9700/9500 this is the 'E' key. On a Pearl, this is the 'T'/'Y' key.</p>
  
  <p>I've managed to get this working in what appears to be a roundabout way, by looking up the keycode of the '2' character <em>with</em> the ALT button enabled and using <code>Keypad.key()</code> to get the actual button:</p>
  
  <pre><code>// figure out which key the '2' is on:
  final int BUTTON_2_KEY = Keypad.key(KeypadUtil.getKeyCode('2', KeypadListener.STATUS_ALT, KeypadUtil.MODE_EN_LOCALE));
  
  protected boolean keyDown(int keycode, int time) {
      int key = Keypad.key(keycode);
      if ( key == BUTTON_2_KEY ) {
         // do something
         return true;
      }
      return super.keyDown(keycode,time);
  }
  </code></pre>
  
  <p>I can't help but wonder if there is a better way to do this. I've looked at the constants defined in <code>KeypadListener</code> and <code>Keypad</code> but I can't find any constants mapped to the actual buttons on the device.</p>
  
  <p>Would any more experienced BlackBerry devs care to lend a helping hand?</p>
  
  <p>Thanks!</p>