isCharacterKey method

bool isCharacterKey (
  1. int keyCode
)

Returns true if the keyCode produces a (US keyboard) character. Note: This does not (yet) cover characters on non-US keyboards (Russian, Hebrew, etc.).

Implementation

static bool isCharacterKey(int keyCode) {
  if ((keyCode >= ZERO && keyCode <= NINE) ||
      (keyCode >= NUM_ZERO && keyCode <= NUM_MULTIPLY) ||
      (keyCode >= A && keyCode <= Z)) {
    return true;
  }

  // Safari sends zero key code for non-latin characters.
  if (Device.isWebKit && keyCode == 0) {
    return true;
  }

  return (keyCode == SPACE ||
      keyCode == QUESTION_MARK ||
      keyCode == NUM_PLUS ||
      keyCode == NUM_MINUS ||
      keyCode == NUM_PERIOD ||
      keyCode == NUM_DIVISION ||
      keyCode == SEMICOLON ||
      keyCode == FF_SEMICOLON ||
      keyCode == DASH ||
      keyCode == EQUALS ||
      keyCode == FF_EQUALS ||
      keyCode == COMMA ||
      keyCode == PERIOD ||
      keyCode == SLASH ||
      keyCode == APOSTROPHE ||
      keyCode == SINGLE_QUOTE ||
      keyCode == OPEN_SQUARE_BRACKET ||
      keyCode == BACKSLASH ||
      keyCode == CLOSE_SQUARE_BRACKET);
}